Qt 4.8
qpushbutton.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qapplication.h"
43 #include "qbitmap.h"
44 #include "qdesktopwidget.h"
45 #include "qdialog.h"
46 #include <private/qdialog_p.h>
47 #include "qdrawutil.h"
48 #include "qevent.h"
49 #include "qfontmetrics.h"
50 #include "qmenu.h"
51 #include "qstylepainter.h"
52 #include "qpixmap.h"
53 #include "qpointer.h"
54 #include "qpushbutton.h"
55 #include "qstyle.h"
56 #include "qstyleoption.h"
57 #include "qtoolbar.h"
58 #include "qdebug.h"
59 #include "qlayoutitem.h"
60 #include "qdialogbuttonbox.h"
61 #ifdef Q_WS_MAC
62 #include "qmacstyle_mac.h"
63 #include "private/qmacstyle_mac_p.h"
64 #endif // Q_WS_MAC
65 
66 #ifndef QT_NO_ACCESSIBILITY
67 #include "qaccessible.h"
68 #endif
69 
70 #include "private/qmenu_p.h"
71 #include "private/qpushbutton_p.h"
72 
74 
75 
258  : QAbstractButton(*new QPushButtonPrivate, parent)
259 {
260  Q_D(QPushButton);
261  d->init();
262 }
263 
270  : QAbstractButton(*new QPushButtonPrivate, parent)
271 {
272  Q_D(QPushButton);
273  setText(text);
274  d->init();
275 }
276 
277 
286  : QAbstractButton(*new QPushButtonPrivate, parent)
287 {
288  Q_D(QPushButton);
289  setText(text);
290  setIcon(icon);
291  d->init();
292 }
293 
297  : QAbstractButton(dd, parent)
298 {
299  Q_D(QPushButton);
300  d->init();
301 }
302 
307 {
308 }
309 
311 {
312  Q_Q(const QPushButton);
313  const QWidget *p = q;
314  while (p && !p->isWindow()) {
315  p = p->parentWidget();
316  if (const QDialog *dialog = qobject_cast<const QDialog *>(p))
317  return const_cast<QDialog *>(dialog);
318  }
319  return 0;
320 }
321 
330 {
331  if (!option)
332  return;
333 
334  Q_D(const QPushButton);
335  option->initFrom(this);
337  if (d->flat)
339 #ifndef QT_NO_MENU
340  if (d->menu)
342 #endif
343  if (autoDefault() || d->defaultButton)
345  if (d->defaultButton)
347  if (d->down || d->menuOpen)
348  option->state |= QStyle::State_Sunken;
349  if (d->checked)
350  option->state |= QStyle::State_On;
351  if (!d->flat && !d->down)
352  option->state |= QStyle::State_Raised;
353  option->text = d->text;
354  option->icon = d->icon;
355  option->iconSize = iconSize();
356 }
357 
359 {
360  Q_D(QPushButton);
362  if (d->autoDefault != QPushButtonPrivate::Auto && d->autoDefault == state)
363  return;
364  d->autoDefault = state;
365  d->sizeHint = QSize();
366  update();
367  updateGeometry();
368 }
369 
370 bool QPushButton::autoDefault() const
371 {
372  Q_D(const QPushButton);
373  if(d->autoDefault == QPushButtonPrivate::Auto)
374  return ( d->dialogParent() != 0 );
375  return d->autoDefault;
376 }
377 
378 void QPushButton::setDefault(bool enable)
379 {
380  Q_D(QPushButton);
381  if (d->defaultButton == enable)
382  return;
383  d->defaultButton = enable;
384  if (d->defaultButton) {
385  if (QDialog *dlg = d->dialogParent())
386  dlg->d_func()->setMainDefault(this);
387  }
388  update();
389 #ifndef QT_NO_ACCESSIBILITY
391 #endif
392 }
393 
395 {
396  Q_D(const QPushButton);
397  return d->defaultButton;
398 }
399 
404 {
405  Q_D(const QPushButton);
406  if (d->sizeHint.isValid() && d->lastAutoDefault == autoDefault())
407  return d->sizeHint;
408  d->lastAutoDefault = autoDefault();
409  ensurePolished();
410 
411  int w = 0, h = 0;
412 
413  QStyleOptionButton opt;
414  initStyleOption(&opt);
415 
416  // calculate contents size...
417 #ifndef QT_NO_ICON
418 
419  bool showButtonBoxIcons = qobject_cast<QDialogButtonBox*>(parentWidget())
421 
422  if (!icon().isNull() || showButtonBoxIcons) {
423  int ih = opt.iconSize.height();
424  int iw = opt.iconSize.width() + 4;
425  w += iw;
426  h = qMax(h, ih);
427  }
428 #endif
429  QString s(text());
430  bool empty = s.isEmpty();
431  if (empty)
432  s = QString::fromLatin1("XXXX");
433  QFontMetrics fm = fontMetrics();
434  QSize sz = fm.size(Qt::TextShowMnemonic, s);
435  if(!empty || !w)
436  w += sz.width();
437  if(!empty || !h)
438  h = qMax(h, sz.height());
439  opt.rect.setSize(QSize(w, h)); // PM_MenuButtonIndicator depends on the height
440 #ifndef QT_NO_MENU
441  if (menu())
442  w += style()->pixelMetric(QStyle::PM_MenuButtonIndicator, &opt, this);
443 #endif
444  d->sizeHint = (style()->sizeFromContents(QStyle::CT_PushButton, &opt, QSize(w, h), this).
445  expandedTo(QApplication::globalStrut()));
446  return d->sizeHint;
447 }
448 
453 {
454  return sizeHint();
455 }
456 
457 
461 {
462  QStylePainter p(this);
463  QStyleOptionButton option;
464  initStyleOption(&option);
466 }
467 
468 
471 {
472  Q_D(QPushButton);
473  switch (e->key()) {
474  case Qt::Key_Enter:
475  case Qt::Key_Return:
476  if (autoDefault() || d->defaultButton) {
477  click();
478  break;
479  }
480  // fall through
481  default:
483  }
484 }
485 
490 {
491  Q_D(QPushButton);
492  if (e->reason() != Qt::PopupFocusReason && autoDefault() && !d->defaultButton) {
493  d->defaultButton = true;
494  QDialog *dlg = qobject_cast<QDialog*>(window());
495  if (dlg)
496  dlg->d_func()->setDefault(this);
497  }
499 }
500 
505 {
506  Q_D(QPushButton);
507  if (e->reason() != Qt::PopupFocusReason && autoDefault() && d->defaultButton) {
508  QDialog *dlg = qobject_cast<QDialog*>(window());
509  if (dlg)
510  dlg->d_func()->setDefault(0);
511  else
512  d->defaultButton = false;
513  }
514 
516 #ifndef QT_NO_MENU
517  if (d->menu && d->menu->isVisible()) // restore pressed status
518  setDown(true);
519 #endif
520 }
521 
522 #ifndef QT_NO_MENU
523 
541 {
542  Q_D(QPushButton);
543  if (menu == d->menu)
544  return;
545 
546  if (menu && !d->menu) {
547  connect(this, SIGNAL(pressed()), this, SLOT(_q_popupPressed()), Qt::UniqueConnection);
548  }
549  if (d->menu)
550  removeAction(d->menu->menuAction());
551  d->menu = menu;
552  if (d->menu)
553  addAction(d->menu->menuAction());
554 
555  d->resetLayoutItemMargins();
556  d->sizeHint = QSize();
557  update();
558  updateGeometry();
559 }
560 
568 {
569  Q_D(const QPushButton);
570  return d->menu;
571 }
572 
579 {
580  Q_D(QPushButton);
581  if (!d || !d->menu)
582  return;
583  setDown(true);
584  d->_q_popupPressed();
585 }
586 
588 {
589  Q_Q(QPushButton);
590  if (!down || !menu)
591  return;
592 
593  menu->setNoReplayFor(q);
594 
595  QPoint menuPos = adjustedMenuPosition();
596 
597  QPointer<QPushButton> guard(q);
599 
600  //Because of a delay in menu effects, we must keep track of the
601  //menu visibility to avoid flicker on button release
602  menuOpen = true;
603  menu->exec(menuPos);
604  if (guard) {
605  menuOpen = false;
606  q->setDown(false);
607  }
608 }
609 
611 {
612  Q_Q(QPushButton);
613 
614  bool horizontal = true;
615 #if !defined(QT_NO_TOOLBAR)
617  if (tb && tb->orientation() == Qt::Vertical)
618  horizontal = false;
619 #endif
620 
621  QWidgetItem item(q);
622  QRect rect = item.geometry();
623  rect.setRect(rect.x() - q->x(), rect.y() - q->y(), rect.width(), rect.height());
624 
625  QSize menuSize = menu->sizeHint();
626  QPoint globalPos = q->mapToGlobal(rect.topLeft());
627  int x = globalPos.x();
628  int y = globalPos.y();
629  if (horizontal) {
630  if (globalPos.y() + rect.height() + menuSize.height() <= QApplication::desktop()->availableGeometry(q).height()) {
631  y += rect.height();
632  } else {
633  y -= menuSize.height();
634  }
635  if (q->layoutDirection() == Qt::RightToLeft)
636  x += rect.width() - menuSize.width();
637  } else {
638  if (globalPos.x() + rect.width() + menu->sizeHint().width() <= QApplication::desktop()->availableGeometry(q).width())
639  x += rect.width();
640  else
641  x -= menuSize.width();
642  }
643 
644  return QPoint(x,y);
645 }
646 
647 #endif // QT_NO_MENU
648 
650 {
651  Q_Q(QPushButton);
652  QStyleOptionButton opt;
653  q->initStyleOption(&opt);
655 }
656 
658 {
659  Q_D(QPushButton);
660  if (d->flat == flat)
661  return;
662  d->flat = flat;
663  d->resetLayoutItemMargins();
664  d->sizeHint = QSize();
665  update();
666  updateGeometry();
667 }
668 
670 {
671  Q_D(const QPushButton);
672  return d->flat;
673 }
674 
677 {
678  Q_D(QPushButton);
679  if (e->type() == QEvent::ParentChange) {
680  if (QDialog *dialog = d->dialogParent()) {
681  if (d->defaultButton)
682  dialog->d_func()->setMainDefault(this);
683  }
684  } else if (e->type() == QEvent::StyleChange
685 #ifdef Q_WS_MAC
686  || e->type() == QEvent::MacSizeChange
687 #endif
688  ) {
689  d->resetLayoutItemMargins();
690  updateGeometry();
691  } else if (e->type() == QEvent::PolishRequest) {
692  updateGeometry();
693  }
694  return QAbstractButton::event(e);
695 }
696 
697 #ifdef Q_WS_MAC
698 
700 {
701  QStyleOptionButton opt;
702  initStyleOption(&opt);
703  if (qt_mac_buttonIsRenderedFlat(this, &opt))
704  return QAbstractButton::hitButton(pos);
705 
706  // Now that we know we are using the native style, let's proceed.
707  Q_D(const QPushButton);
708  QPushButtonPrivate *nonConst = const_cast<QPushButtonPrivate *>(d);
709  // In OSX buttons are round, which causes the hit method to be special.
710  // We cannot simply relay on detecting if something is inside the rect or not,
711  // we need to check if it is inside the "rounded area" or not. A point might
712  // be inside the rect but not inside the rounded area.
713  // Notice this method is only reimplemented for OSX.
714  return nonConst->hitButton(pos);
715 }
716 
718 {
719  Q_Q(QPushButton);
720  QRect roundedRect(q->rect().left() + QMacStylePrivate::PushButtonLeftOffset,
722  q->rect().width() - QMacStylePrivate::PushButtonRightOffset,
723  q->rect().height() - QMacStylePrivate::PushButtonBottomOffset);
724  return roundedRect.contains(pos);
725 }
726 #endif // Q_WS_MAC
727 
728 #ifdef QT3_SUPPORT
729 
734  : QAbstractButton(*new QPushButtonPrivate, parent)
735 {
736  Q_D(QPushButton);
738  d->init();
739 }
740 
745 QPushButton::QPushButton(const QString &text, QWidget *parent, const char *name)
746  : QAbstractButton(*new QPushButtonPrivate, parent)
747 {
748  Q_D(QPushButton);
750  setText(text);
751  d->init();
752 }
753 
758 QPushButton::QPushButton(const QIcon& icon, const QString &text, QWidget *parent, const char *name)
759  : QAbstractButton(*new QPushButtonPrivate, parent)
760 {
761  Q_D(QPushButton);
763  setText(text);
764  setIcon(icon);
765  d->init();
766 }
767 #endif
768 
800 
801 #include "moc_qpushbutton.cpp"
QSize iconSize
the size of the icon for the button
Definition: qstyleoption.h:292
The QAbstractButton class is the abstract base class of button widgets, providing functionality commo...
QPoint pos() const
double d
Definition: qnumeric_p.h:62
static void updateAccessibility(QObject *, int who, Event reason)
Notifies accessibility clients about a change in object&#39;s accessibility information.
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
The QKeyEvent class describes a key event.
Definition: qevent.h:224
int y() const
The QFontMetrics class provides font metrics information.
Definition: qfontmetrics.h:65
void setNoReplayFor(QWidget *widget)
Definition: qmenu.cpp:3164
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QString text() const
void setText(const QString &text)
bool hitButton(const QPoint &pos)
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
void showMenu()
Shows (pops up) the associated popup menu.
void drawControl(QStyle::ControlElement ce, const QStyleOption &opt)
Use the widget&#39;s style to draw a control element ce specified by QStyleOption option.
Definition: qstylepainter.h:87
void ensurePolished() const
Ensures that the widget has been polished by QStyle (i.e., has a proper font and palette).
Definition: qwidget.cpp:10024
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
The QDialog class is the base class of dialog windows.
Definition: qdialog.h:56
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
static QSize globalStrut()
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
#define SLOT(a)
Definition: qobjectdefs.h:226
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
static const int PushButtonBottomOffset
QSize sizeHint() const
Reimplemented Function
Definition: qmenu.cpp:1805
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
void setDefault(bool)
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
The QPushButton widget provides a command button.
Definition: qpushbutton.h:57
bool flat
whether the button border is raised
Definition: qpushbutton.h:63
void paintEvent(QPaintEvent *)
Reimplemented Function
void pressed()
This signal is emitted when the button is pressed down.
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
QString text
the text of the button
Definition: qstyleoption.h:290
The QString class provides a Unicode character string.
Definition: qstring.h:83
T * qobject_cast(QObject *object)
Definition: qobject.h:375
QPushButton(QWidget *parent=0)
Constructs a push button with no text and a parent.
#define Q_D(Class)
Definition: qglobal.h:2482
bool autoDefault() const
void addAction(QAction *action)
Appends the action action to this widget&#39;s list of actions.
Definition: qwidget.cpp:3317
void focusOutEvent(QFocusEvent *e)
Reimplemented Function
static const int PushButtonLeftOffset
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
QStyle * style() const
Definition: qwidget.cpp:2742
void setObjectName(const QString &name)
Definition: qobject.cpp:1112
#define Q_Q(Class)
Definition: qglobal.h:2483
QAbstractButton(QWidget *parent=0)
Constructs an abstract button with a parent.
QPoint adjustedMenuPosition()
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
int key() const
Returns the code of the key that was pressed or released.
Definition: qevent.h:231
#define SIGNAL(a)
Definition: qobjectdefs.h:227
bool event(QEvent *e)
Reimplemented Function
int width() const
Returns the width.
Definition: qsize.h:126
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
void resetLayoutItemMargins()
void keyPressEvent(QKeyEvent *e)
Reimplemented Function
QSize size(int flags, const QString &str, int tabstops=0, int *tabarray=0) const
Returns the size in pixels of text.
void initStyleOption(QStyleOptionButton *option) const
Initialize option with the values from this QPushButton.
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
void setMenu(QMenu *menu)
Associates the popup menu menu with this push button.
The QToolBar class provides a movable panel that contains a set of controls.
Definition: qtoolbar.h:62
void initFrom(const QWidget *w)
Definition: qstyleoption.h:99
const char * name
QIcon icon
the icon of the button
Definition: qstyleoption.h:291
void focusInEvent(QFocusEvent *e)
Reimplemented Function
QDialog * dialogParent() const
bool event(QEvent *e)
Reimplemented Function
QFontMetrics fontMetrics() const
Returns the font metrics for the widget&#39;s current font.
Definition: qwidget.h:984
void setSize(const QSize &s)
Sets the size of the rectangle to the given size.
Definition: qrect.h:448
unsigned int uint
Definition: qglobal.h:996
~QPushButton()
Destroys the push button.
void keyPressEvent(QKeyEvent *)
Reimplemented Function
QSize sizeHint() const
Reimplemented Function
bool qt_mac_buttonIsRenderedFlat(const QPushButton *pushButton, const QStyleOptionButton *option)
ButtonFeatures features
a bitwise OR of the features that describe this button
Definition: qstyleoption.h:289
QMenu * menu() const
Returns the button&#39;s associated popup menu or 0 if no popup menu has been set.
void focusInEvent(QFocusEvent *)
Reimplemented Function
The QWidgetItem class is a layout item that represents a widget.
Definition: qlayoutitem.h:122
QRect rect() const
bool contains(const QPoint &p, bool proper=false) const
Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false...
Definition: qrect.cpp:1101
bool hitButton(const QPoint &pos) const
Reimplemented Function
QMenuCaused causedPopup
Definition: qmenu_p.h:263
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
virtual QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w=0) const =0
Returns the size of the element described by the specified option and type, based on the provided con...
QAction * exec()
Executes this menu synchronously.
Definition: qmenu.cpp:2101
QSize iconSize() const
bool down
whether the button is pressed down
void setAutoDefault(bool)
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
int x() const
Qt::Orientation orientation() const
orientation of the toolbar
Definition: qtoolbar.cpp:769
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
The QDialogButtonBox class is a widget that presents buttons in a layout that is appropriate to the c...
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
void setRect(int x, int y, int w, int h)
Sets the coordinates of the rectangle&#39;s top-left corner to ({x}, {y}), and its size to the given widt...
Definition: qrect.h:400
void removeAction(QAction *action)
Removes the action action from this widget&#39;s list of actions.
Definition: qwidget.cpp:3386
QRect geometry() const
Reimplemented Function
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void focusOutEvent(QFocusEvent *)
Reimplemented Function
int height() const
Returns the height.
Definition: qsize.h:129
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
static const int PushButtonContentPadding
bool isDefault() const
Qt::FocusReason reason()
Definition: qevent.cpp:1197
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
static const int PushButtonRightOffset
The QStylePainter class is a convenience class for drawing QStyle elements inside a widget...
Definition: qstylepainter.h:55
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
void click()
Performs a click.
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
const QRect availableGeometry(int screen=-1) const
void updateGeometry()
Notifies the layout system that this widget has changed and may need to change geometry.
Definition: qwidget.cpp:10372
virtual bool hitButton(const QPoint &pos) const
Returns true if pos is inside the clickable button rectangle; otherwise returns false.
The QPaintEvent class contains event parameters for paint events.
Definition: qevent.h:298
void setIcon(const QIcon &icon)
static void setLayoutItemMargins(int left, int top, int right, int bottom, QRect *rect, Qt::LayoutDirection dir)
static QMenuPrivate * get(QMenu *m)
Definition: qmenu_p.h:186
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
bool isFlat() const
The QStyleOptionButton class is used to describe the parameters for drawing buttons.
Definition: qstyleoption.h:279
QPointer< QWidget > widget
Definition: qmenu_p.h:259
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
The QFocusEvent class contains event parameters for widget focus events.
Definition: qevent.h:275
void setFlat(bool)
QSize minimumSizeHint() const
Reimplemented Function
static bool isNull(const QVariant::Private *d)
Definition: qvariant.cpp:300
QIcon icon() const
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60