Qt 4.8
Public Types | Public Functions | Public Variables | List of all members
QToolButtonPrivate Class Reference
Inheritance diagram for QToolButtonPrivate:
QAbstractButtonPrivate QWidgetPrivate QObjectPrivate QObjectData

Public Types

enum  { NoButtonPressed =0, MenuButtonPressed =1, ToolButtonPressed =2 }
 
- Public Types inherited from QWidgetPrivate
enum  CloseMode { CloseNoEvent, CloseWithEvent, CloseWithSpontaneousEvent }
 
enum  Direction { DirectionNorth = 0x01, DirectionEast = 0x10, DirectionSouth = 0x02, DirectionWest = 0x20 }
 
enum  DrawWidgetFlags {
  DrawAsRoot = 0x01, DrawPaintOnScreen = 0x02, DrawRecursive = 0x04, DrawInvisible = 0x08,
  DontSubtractOpaqueChildren = 0x10, DontSetCompositionMode = 0x20, DontDrawOpaqueChildren = 0x40, DontDrawNativeChildren = 0x80
}
 
- Public Types inherited from QObjectPrivate
typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
 

Public Functions

void _q_actionTriggered ()
 
void _q_buttonPressed ()
 
void _q_menuTriggered (QAction *)
 
void _q_updateButtonDown ()
 
bool hasMenu () const
 
void init ()
 
QStyle::SubControl newHoverControl (const QPoint &pos)
 
void popupTimerDone ()
 
bool updateHoverControl (const QPoint &pos)
 
- Public Functions inherited from QAbstractButtonPrivate
void click ()
 
void emitClicked ()
 
void emitPressed ()
 
void emitReleased ()
 
void fixFocusPolicy ()
 
void init ()
 
void moveFocus (int key)
 
void notifyChecked ()
 
 QAbstractButtonPrivate (QSizePolicy::ControlType type=QSizePolicy::DefaultType)
 
QList< QAbstractButton * > queryButtonList () const
 
QAbstractButtonqueryCheckedButton () const
 
void refresh ()
 
- Public Functions inherited from QWidgetPrivate
void _q_showIfNotHidden ()
 
virtual void aboutToDestroy ()
 
void activateChildLayoutsRecursively ()
 
QSize adjustedSize () const
 
void adjustQuitOnCloseAttribute ()
 
QInputContextassignedInputContext () const
 
QPainterbeginSharedPainter ()
 
QWidgetchildAt_helper (const QPoint &, bool) const
 
QWidgetchildAtRecursiveHelper (const QPoint &p, bool, bool includeFrame=false) const
 
QRect clipRect () const
 
QRegion clipRegion () const
 
void clipToEffectiveMask (QRegion &region) const
 
bool close_helper (CloseMode mode)
 
void create_sys (WId window, bool initializeWindow, bool destroyOldWindow)
 
QWindowSurfacecreateDefaultWindowSurface ()
 
QWindowSurfacecreateDefaultWindowSurface_sys ()
 
void createExtra ()
 Creates the widget extra data. More...
 
void createRecursively ()
 
void createSysExtra ()
 
void createTLExtra ()
 
void createTLSysExtra ()
 
void createWinId (WId id=0)
 
void deactivateWidgetCleanup ()
 
void deleteExtra ()
 Deletes the widget extra data. More...
 
void deleteSysExtra ()
 
void deleteTLSysExtra ()
 
void drawWidget (QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags, QPainter *sharedPainter=0, QWidgetBackingStore *backingStore=0)
 
QWidgeteffectiveFocusWidget ()
 
QRect effectiveRectFor (const QRect &rect) const
 
bool endSharedPainter ()
 
void enforceNativeChildren ()
 
QWExtraextraData () const
 
QRect frameStrut () const
 
void getLayoutItemMargins (int *left, int *top, int *right, int *bottom) const
 
const QRegiongetOpaqueChildren () const
 
void handleSoftwareInputPanel (Qt::MouseButton button, bool clickCausedFocus)
 
virtual bool hasHeightForWidth () const
 
void hide_helper ()
 
void hide_sys ()
 Platform-specific part of QWidget::hide(). More...
 
void hideChildren (bool spontaneous)
 
void inheritStyle ()
 
void init (QWidget *desktopWidget, Qt::WindowFlags f)
 
QInputContextinputContext () const
 
void invalidateBuffer (const QRegion &)
 Invalidates the rgn (in widget's coordinates) of the backing store, i.e. More...
 
void invalidateBuffer (const QRect &)
 This function is equivalent to calling invalidateBuffer(QRegion(rect), ...), but is more efficient as it eliminates QRegion operations/allocations and can use the rect more precisely for additional cut-offs. More...
 
void invalidateBuffer_resizeHelper (const QPoint &oldPos, const QSize &oldSize)
 Invalidates the buffer when the widget is resized. More...
 
void invalidateGraphicsEffectsRecursively ()
 
bool isAboutToShow () const
 
bool isBackgroundInherited () const
 
bool isOverlapped (const QRect &) const
 
void lower_sys ()
 
QPoint mapFromGlobal (const QPoint &pos) const
 
QPoint mapToGlobal (const QPoint &pos) const
 
QWidgetBackingStoremaybeBackingStore () const
 
QTLWExtramaybeTopData () const
 
void moveRect (const QRect &, int dx, int dy)
 
bool nativeChildrenForced () const
 
QFont naturalWidgetFont (uint inheritedMask) const
 
QPalette naturalWidgetPalette (uint inheritedMask) const
 Returns the palette that the widget w inherits from its ancestors and QApplication::palette. More...
 
void paintBackground (QPainter *, const QRegion &, int flags=DrawAsRoot) const
 
bool paintOnScreen () const
 
void paintSiblingsRecursive (QPaintDevice *pdev, const QObjectList &children, int index, const QRegion &rgn, const QPoint &offset, int flags, QPainter *sharedPainter, QWidgetBackingStore *backingStore)
 
bool pointInsideRectAndMask (const QPoint &) const
 
QRegion prepareToRender (const QRegion &region, QWidget::RenderFlags renderFlags)
 
void propagatePaletteChange ()
 Propagate this widget's palette to all children, except style sheet widgets, and windows that don't enable window propagation (palettes don't normally propagate to windows). More...
 
 QWidgetPrivate (int version=QObjectPrivateVersion)
 
void raise_sys ()
 
QPaintDeviceredirected (QPoint *offset) const
 
void registerDropSite (bool)
 
void render (QPaintDevice *target, const QPoint &targetOffset, const QRegion &sourceRegion, QWidget::RenderFlags renderFlags, bool readyToRender)
 
void render_helper (QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion, QWidget::RenderFlags renderFlags)
 
void repaint_sys (const QRegion &rgn)
 
void reparentFocusWidgets (QWidget *oldtlw)
 
void resolveFont ()
 Determine which font is implicitly imposed on this widget by its ancestors and QApplication::font, resolve this against its own font (attributes from the implicit font are copied over). More...
 
void resolveLayoutDirection ()
 
void resolveLocale ()
 
void resolvePalette ()
 Determine which palette is inherited from this widget's ancestors and QApplication::palette, resolve this against this widget's palette (attributes from the inherited palette are copied over this widget's palette). More...
 
void restoreRedirected ()
 
void scroll_sys (int dx, int dy)
 
void scroll_sys (int dx, int dy, const QRect &r)
 
void scrollChildren (int dx, int dy)
 
void scrollRect (const QRect &, int dx, int dy)
 
void sendPendingMoveAndResizeEvents (bool recursive=false, bool disableUpdates=false)
 
void sendStartupMessage (const char *message) const
 Platform-specific part of QWidget::show(). More...
 
void setConstraints_sys ()
 
void setCursor_sys (const QCursor &cursor)
 
void setDirtyOpaqueRegion ()
 
void setEnabled_helper (bool)
 
void setFocus_sys ()
 
void setFont_helper (const QFont &font)
 
void setGeometry_sys (int, int, int, int, bool)
 
void setLayoutDirection_helper (Qt::LayoutDirection)
 
void setLayoutItemMargins (int left, int top, int right, int bottom)
 
void setLayoutItemMargins (QStyle::SubElement element, const QStyleOption *opt=0)
 
void setLocale_helper (const QLocale &l, bool forceUpdate=false)
 
void setMask_sys (const QRegion &)
 
bool setMaximumSize_helper (int &maxw, int &maxh)
 
bool setMinimumSize_helper (int &minw, int &minh)
 
void setModal_sys ()
 
void setNetWmWindowTypes ()
 
void setOpaque (bool opaque)
 
void setPalette_helper (const QPalette &)
 
void setParent_sys (QWidget *parent, Qt::WindowFlags)
 
void setRedirected (QPaintDevice *replacement, const QPoint &offset)
 
void setSharedPainter (QPainter *painter)
 
void setStyle_helper (QStyle *newStyle, bool propagate, bool metalHack=false)
 
void setUpdatesEnabled_helper (bool)
 
void setWindowFilePath_helper (const QString &filePath)
 
void setWindowIcon_helper ()
 
void setWindowIcon_sys (bool forceReset=false)
 
void setWindowIconText_helper (const QString &cap)
 
void setWindowIconText_sys (const QString &cap)
 
void setWindowOpacity_sys (qreal opacity)
 
void setWindowRole ()
 
void setWindowTitle_helper (const QString &cap)
 
void setWindowTitle_sys (const QString &cap)
 
void setWinId (WId)
 
QPaintersharedPainter () const
 
void show_helper ()
 
void show_recursive ()
 Makes the widget visible in the isVisible() meaning of the word. More...
 
void show_sys ()
 Platform-specific part of QWidget::show(). More...
 
void showChildren (bool spontaneous)
 
void stackUnder_sys (QWidget *)
 
void subtractOpaqueChildren (QRegion &rgn, const QRect &clipRect) const
 
void subtractOpaqueSiblings (QRegion &source, bool *hasDirtySiblingsAbove=0, bool alsoNonOpaque=false) const
 
void syncBackingStore ()
 
void syncBackingStore (const QRegion &region)
 
QTLWExtratopData () const
 
void unsetCursor_sys ()
 
void updateFont (const QFont &)
 Assign font to this widget, and propagate it to all children, except style sheet widgets (handled differently) and windows that don't enable window propagation. More...
 
void updateFrameStrut ()
 Computes the frame rectangle when needed. More...
 
void updateGeometry_helper (bool forceUpdate)
 
void updateIsOpaque ()
 
void updateIsTranslucent ()
 
void updateSystemBackground ()
 
void updateX11AcceptFocus ()
 
void x11UpdateIsOpaque ()
 
 ~QWidgetPrivate ()
 
- Public Functions inherited from QObjectPrivate
void _q_reregisterTimers (void *pointer)
 
void addConnection (int signal, Connection *c)
 
void cleanConnectionLists ()
 
void connectNotify (const char *signal)
 
void deleteChildren ()
 
void disconnectNotify (const char *signal)
 
bool isSender (const QObject *receiver, const char *signal) const
 
bool isSignalConnected (uint signalIdx) const
 Returns true if the signal with index signal_index from object sender is connected. More...
 
void moveToThread_helper ()
 
 QObjectPrivate (int version=QObjectPrivateVersion)
 
QObjectList receiverList (const char *signal) const
 
QObjectList senderList () const
 
void setParent_helper (QObject *)
 
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData)
 
int signalIndex (const char *signalName) const
 Returns the signal index used in the internal connectionLists vector. More...
 
virtual ~QObjectPrivate ()
 
- Public Functions inherited from QObjectData
virtual ~QObjectData ()=0
 

Public Variables

QList< QAction * > actionsCopy
 
Qt::ArrowType arrowType
 
uint autoRaise: 1
 
uint buttonPressed: 2
 
QActiondefaultAction
 
int delay
 
QStyle::SubControl hoverControl
 
QRect hoverRect
 
QPointer< QActionmenuAction
 
uint menuButtonDown: 1
 
QToolButton::ToolButtonPopupMode popupMode
 
QBasicTimer popupTimer
 
uint repeat: 1
 
Qt::ToolButtonStyle toolButtonStyle
 
- Public Variables inherited from QAbstractButtonPrivate
QBasicTimer animateTimer
 
uint autoExclusive:1
 
uint autoRepeat:1
 
int autoRepeatDelay
 
int autoRepeatInterval
 
uint blockRefresh:1
 
uint checkable:1
 
uint checked:1
 
QSizePolicy::ControlType controlType
 
uint down:1
 
QButtonGroupgroup
 
QIcon icon
 
QSize iconSize
 
uint pressed: 1
 
QBasicTimer repeatTimer
 
QKeySequence shortcut
 
int shortcutId
 
QSize sizeHint
 
QString text
 
- Public Variables inherited from QWidgetPrivate
QString accessibleDescription
 
QString accessibleName
 
QList< QAction * > actions
 
QPalette::ColorRole bg_role: 8
 
signed char bottomLayoutItemMargin
 
short bottommargin
 
QWidgetData data
 
QRegion dirty
 
uint dirtyOpaqueChildren: 1
 
QWExtraextra
 
QPaintEngineextraPaintEngine
 
QPalette::ColorRole fg_role: 8
 
QWidgetfocus_child
 
QWidgetfocus_next
 
QWidgetfocus_prev
 
QMap< Qt::GestureType, Qt::GestureFlags > gestureContext
 
QGraphicsEffectgraphicsEffect
 
Qt::HANDLE hd
 
uint high_attributes [4]
 
QPointer< QInputContextic
 
Qt::InputMethodHints imHints
 
uint inDirtyList: 1
 
uint inheritedFontResolveMask
 
uint inheritedPaletteResolveMask
 
uint inheritsInputMethodHints: 1
 
uint inSetParent: 1
 
uint isGLWidget: 1
 
uint isMoved: 1
 
uint isOpaque: 1
 
uint isScrolled: 1
 
QLayoutlayout
 
signed char leftLayoutItemMargin
 
short leftmargin
 
QLocale locale
 
QRegionneedsFlush
 
QRegion opaqueChildren
 
Qt::HANDLE picture
 
const QMetaObjectpolished
 
QPaintDeviceredirectDev
 
QPoint redirectOffset
 
signed char rightLayoutItemMargin
 
short rightmargin
 
QSizePolicy size_policy
 
QString statusTip
 
QString toolTip
 
signed char topLayoutItemMargin
 
short topmargin
 
uint usesDoubleBufferedGLContext: 1
 
QString whatsThis
 
QWidgetItemV2widgetItem
 
QX11Info xinfo
 
- Public Variables inherited from QObjectPrivate
union {
   QObject *   currentChildBeingDeleted
 
   QAbstractDeclarativeData *   declarativeData
 
}; 
 
quint32 connectedSignals [2]
 
QObjectConnectionListVectorconnectionLists
 
SendercurrentSender
 
QList< QPointer< QObject > > eventFilters
 
ExtraDataextraData
 
QString objectName
 
Connectionsenders
 
QAtomicPointer< QtSharedPointer::ExternalRefCountData > sharedRefcount
 
QThreadDatathreadData
 
void * unused
 
- Public Variables inherited from QObjectData
uint blockSig: 1
 
QObjectList children
 
uint hasGuards: 1
 
uint inEventHandler: 1
 
uint inThreadChangeEvent: 1
 
uint isWidget: 1
 
QMetaObjectmetaObject
 
uint ownObjectName: 1
 
QObjectparent
 
uint pendTimer: 1
 
int postedEvents
 
QObjectq_ptr
 
uint receiveChildEvents: 1
 
uint sendChildEvents: 1
 
uint unused: 22
 
uint wasDeleted: 1
 

Additional Inherited Members

- Static Public Functions inherited from QWidgetPrivate
static void adjustFlags (Qt::WindowFlags &flags, QWidget *w=0)
 
static QGraphicsProxyWidgetnearestGraphicsProxyWidget (const QWidget *origin)
 Finds the nearest widget embedded in a graphics proxy widget along the chain formed by this widget and its ancestors. More...
 
static int pointToRect (const QPoint &p, const QRect &r)
 
static QRect screenGeometry (const QWidget *widget)
 
- Static Public Functions inherited from QObjectPrivate
static void clearGuards (QObject *)
 
static QObjectPrivateget (QObject *o)
 
static void resetCurrentSender (QObject *receiver, Sender *currentSender, Sender *previousSender)
 
static SendersetCurrentSender (QObject *receiver, Sender *sender)
 
static void signalSignature (const QMetaMethod &signal, QVarLengthArray< char > *result)
 
- Static Public Variables inherited from QWidgetPrivate
static QWidgetSetallWidgets = 0
 
static int instanceCounter = 0
 
static QWidgetkeyboardGrabber = 0
 
static QWidgetMappermapper = 0
 
static int maxInstances = 0
 
static QWidgetmouseGrabber = 0
 

Detailed Description

Definition at line 66 of file qtoolbutton.cpp.

Enumerations

◆ anonymous enum

anonymous enum
Enumerator
NoButtonPressed 
MenuButtonPressed 
ToolButtonPressed 

Definition at line 88 of file qtoolbutton.cpp.

Functions

◆ _q_actionTriggered()

void QToolButtonPrivate::_q_actionTriggered ( )

Definition at line 631 of file qtoolbutton.cpp.

632 {
633  Q_Q(QToolButton);
634  if (QAction *action = qobject_cast<QAction *>(q->sender()))
635  emit q->triggered(action);
636 }
#define Q_Q(Class)
Definition: qglobal.h:2483
#define emit
Definition: qobjectdefs.h:76
The QToolButton class provides a quick-access button to commands or options, usually used inside a QT...
Definition: qtoolbutton.h:59
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64

◆ _q_buttonPressed()

void QToolButtonPrivate::_q_buttonPressed ( )

Definition at line 898 of file qtoolbutton.cpp.

899 {
900  Q_Q(QToolButton);
901  if (!hasMenu())
902  return; // no menu to show
904  return;
906  popupTimer.start(delay, q);
907  else if (delay == 0 || popupMode == QToolButton::InstantPopup)
908  q->showMenu();
909 }
QBasicTimer popupTimer
Definition: qtoolbutton.cpp:83
bool isActive() const
Returns true if the timer is running and has not been stopped; otherwise returns false.
Definition: qbasictimer.h:62
#define Q_Q(Class)
Definition: qglobal.h:2483
QToolButton::ToolButtonPopupMode popupMode
Definition: qtoolbutton.cpp:87
bool hasMenu() const
The QToolButton class provides a quick-access button to commands or options, usually used inside a QT...
Definition: qtoolbutton.h:59
void start(int msec, QObject *obj)
Starts (or restarts) the timer with a msec milliseconds timeout.

◆ _q_menuTriggered()

void QToolButtonPrivate::_q_menuTriggered ( QAction action)

Definition at line 1010 of file qtoolbutton.cpp.

1011 {
1012  Q_Q(QToolButton);
1013  if (action && !actionsCopy.contains(action))
1014  emit q->triggered(action);
1015 }
#define Q_Q(Class)
Definition: qglobal.h:2483
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
Definition: qlist.h:880
#define emit
Definition: qobjectdefs.h:76
QList< QAction * > actionsCopy
Definition: qtoolbutton.cpp:97
The QToolButton class provides a quick-access button to commands or options, usually used inside a QT...
Definition: qtoolbutton.h:59

◆ _q_updateButtonDown()

void QToolButtonPrivate::_q_updateButtonDown ( )

Definition at line 1000 of file qtoolbutton.cpp.

1001 {
1002  Q_Q(QToolButton);
1003  menuButtonDown = false;
1004  if (q->isDown())
1005  q->setDown(false);
1006  else
1007  q->repaint();
1008 }
#define Q_Q(Class)
Definition: qglobal.h:2483
The QToolButton class provides a quick-access button to commands or options, usually used inside a QT...
Definition: qtoolbutton.h:59

◆ hasMenu()

bool QToolButtonPrivate::hasMenu ( ) const

Definition at line 105 of file qtoolbutton.cpp.

106 {
107  return ((defaultAction && defaultAction->menu())
108  || (menuAction && menuAction->menu())
109  || actions.size() > (defaultAction ? 1 : 0));
110 }
QAction * defaultAction
Definition: qtoolbutton.cpp:93
QMenu * menu() const
Returns the menu contained by this action.
Definition: qaction.cpp:793
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QList< QAction * > actions
Definition: qwidget_p.h:760
QPointer< QAction > menuAction
Definition: qtoolbutton.cpp:82

◆ init()

void QToolButtonPrivate::init ( )

Definition at line 274 of file qtoolbutton.cpp.

275 {
276  Q_Q(QToolButton);
277  delay = q->style()->styleHint(QStyle::SH_ToolButton_PopupDelay, 0, q);
278 #ifdef QT3_SUPPORT
279  userDefinedPopupDelay = false;
280 #endif
281  defaultAction = 0;
282 #ifndef QT_NO_TOOLBAR
283  if (qobject_cast<QToolBar*>(parent))
284  autoRaise = true;
285  else
286 #endif
287  autoRaise = false;
289  menuButtonDown = false;
292 
295 
296  q->setFocusPolicy(Qt::TabFocus);
299 
300 #ifndef QT_NO_MENU
302 #endif
303 
305 
306 }
QStyle::SubControl hoverControl
Definition: qtoolbutton.cpp:80
#define SLOT(a)
Definition: qobjectdefs.h:226
void setLayoutItemMargins(int left, int top, int right, int bottom)
Definition: qwidget.cpp:12860
#define Q_Q(Class)
Definition: qglobal.h:2483
QToolButton::ToolButtonPopupMode popupMode
Definition: qtoolbutton.cpp:87
#define SIGNAL(a)
Definition: qobjectdefs.h:227
QAction * defaultAction
Definition: qtoolbutton.cpp:93
Qt::ArrowType arrowType
Definition: qtoolbutton.cpp:85
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
Qt::ToolButtonStyle toolButtonStyle
Definition: qtoolbutton.cpp:86
QObject * parent
Definition: qobject.h:92
The QToolButton class provides a quick-access button to commands or options, usually used inside a QT...
Definition: qtoolbutton.h:59

◆ newHoverControl()

QStyle::SubControl QToolButtonPrivate::newHoverControl ( const QPoint pos)

Definition at line 603 of file qtoolbutton.cpp.

604 {
605  Q_Q(QToolButton);
607  q->initStyleOption(&opt);
609  hoverControl = q->style()->hitTestComplexControl(QStyle::CC_ToolButton, &opt, pos, q);
611  hoverRect = QRect();
612  else
613  hoverRect = q->style()->subControlRect(QStyle::CC_ToolButton, &opt, hoverControl, q);
614  return hoverControl;
615 }
QStyle::SubControl hoverControl
Definition: qtoolbutton.cpp:80
The QStyleOptionToolButton class is used to describe the parameters for drawing a tool button...
Definition: qstyleoption.h:768
#define Q_Q(Class)
Definition: qglobal.h:2483
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QToolButton class provides a quick-access button to commands or options, usually used inside a QT...
Definition: qtoolbutton.h:59
QStyle::SubControls subControls
This variable holds a bitwise OR of the sub-controls to be drawn for the complex control.
Definition: qstyleoption.h:693

◆ popupTimerDone()

void QToolButtonPrivate::popupTimerDone ( )

Definition at line 911 of file qtoolbutton.cpp.

912 {
913  Q_Q(QToolButton);
914  popupTimer.stop();
915  if (!menuButtonDown && !down)
916  return;
917 
918  menuButtonDown = true;
919  QPointer<QMenu> actualMenu;
920  bool mustDeleteActualMenu = false;
921  if(menuAction) {
922  actualMenu = menuAction->menu();
923  } else if (defaultAction && defaultAction->menu()) {
924  actualMenu = defaultAction->menu();
925  } else {
926  actualMenu = new QMenu(q);
927  mustDeleteActualMenu = true;
928  for(int i = 0; i < actions.size(); i++)
929  actualMenu->addAction(actions.at(i));
930  }
931  repeat = q->autoRepeat();
932  q->setAutoRepeat(false);
933  bool horizontal = true;
934 #if !defined(QT_NO_TOOLBAR)
936  if (tb && tb->orientation() == Qt::Vertical)
937  horizontal = false;
938 #endif
939  QPoint p;
941  QSize sh = ((QToolButton*)(QMenu*)actualMenu)->receivers(SIGNAL(aboutToShow()))? QSize() : actualMenu->sizeHint();
942  QRect rect = q->rect();
943  if (horizontal) {
944  if (q->isRightToLeft()) {
945  if (q->mapToGlobal(QPoint(0, rect.bottom())).y() + sh.height() <= screen.height()) {
946  p = q->mapToGlobal(rect.bottomRight());
947  } else {
948  p = q->mapToGlobal(rect.topRight() - QPoint(0, sh.height()));
949  }
950  p.rx() -= sh.width();
951  } else {
952  if (q->mapToGlobal(QPoint(0, rect.bottom())).y() + sh.height() <= screen.height()) {
953  p = q->mapToGlobal(rect.bottomLeft());
954  } else {
955  p = q->mapToGlobal(rect.topLeft() - QPoint(0, sh.height()));
956  }
957  }
958  } else {
959  if (q->isRightToLeft()) {
960  if (q->mapToGlobal(QPoint(rect.left(), 0)).x() - sh.width() <= screen.x()) {
961  p = q->mapToGlobal(rect.topRight());
962  } else {
963  p = q->mapToGlobal(rect.topLeft());
964  p.rx() -= sh.width();
965  }
966  } else {
967  if (q->mapToGlobal(QPoint(rect.right(), 0)).x() + sh.width() <= screen.right()) {
968  p = q->mapToGlobal(rect.topRight());
969  } else {
970  p = q->mapToGlobal(rect.topLeft() - QPoint(sh.width(), 0));
971  }
972  }
973  }
974  p.rx() = qMax(screen.left(), qMin(p.x(), screen.right() - sh.width()));
975  p.ry() += 1;
976  QPointer<QToolButton> that = q;
977  actualMenu->setNoReplayFor(q);
978  if (!mustDeleteActualMenu) //only if action are not in this widget
979  QObject::connect(actualMenu, SIGNAL(triggered(QAction*)), q, SLOT(_q_menuTriggered(QAction*)));
980  QObject::connect(actualMenu, SIGNAL(aboutToHide()), q, SLOT(_q_updateButtonDown()));
981  actualMenu->d_func()->causedPopup.widget = q;
982  actualMenu->d_func()->causedPopup.action = defaultAction;
983  actionsCopy = q->actions(); //(the list of action may be modified in slots)
984  actualMenu->exec(p);
985  QObject::disconnect(actualMenu, SIGNAL(aboutToHide()), q, SLOT(_q_updateButtonDown()));
986  if (mustDeleteActualMenu)
987  delete actualMenu;
988  else
989  QObject::disconnect(actualMenu, SIGNAL(triggered(QAction*)), q, SLOT(_q_menuTriggered(QAction*)));
990 
991  if (!that)
992  return;
993 
994  actionsCopy.clear();
995 
996  if (repeat)
997  q->setAutoRepeat(true);
998 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
QBasicTimer popupTimer
Definition: qtoolbutton.cpp:83
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
void setNoReplayFor(QWidget *widget)
Definition: qmenu.cpp:3164
#define SLOT(a)
Definition: qobjectdefs.h:226
void _q_menuTriggered(QAction *)
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int & ry()
Returns a reference to the y coordinate of this point.
Definition: qpoint.h:143
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
QAction * addAction(const QString &text)
This convenience function creates a new action with text.
Definition: qmenu.cpp:1453
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
#define Q_Q(Class)
Definition: qglobal.h:2483
#define SIGNAL(a)
Definition: qobjectdefs.h:227
int width() const
Returns the width.
Definition: qsize.h:126
QAction * defaultAction
Definition: qtoolbutton.cpp:93
QPoint bottomRight() const
Returns the position of the rectangle&#39;s bottom-right corner.
Definition: qrect.h:291
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
The QToolBar class provides a movable panel that contains a set of controls.
Definition: qtoolbar.h:62
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
int & rx()
Returns a reference to the x coordinate of this point.
Definition: qpoint.h:140
QList< QAction * > actionsCopy
Definition: qtoolbutton.cpp:97
void clear()
Removes all items from the list.
Definition: qlist.h:764
void stop()
Stops the timer.
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
QPoint topRight() const
Returns the position of the rectangle&#39;s top-right corner.
Definition: qrect.h:294
QAction * exec()
Executes this menu synchronously.
Definition: qmenu.cpp:2101
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
Definition: qobject.cpp:2895
QMenu * menu() const
Returns the menu contained by this action.
Definition: qaction.cpp:793
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
QPoint bottomLeft() const
Returns the position of the rectangle&#39;s bottom-left corner.
Definition: qrect.h:297
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
Qt::Orientation orientation() const
orientation of the toolbar
Definition: qtoolbar.cpp:769
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
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
QList< QAction * > actions
Definition: qwidget_p.h:760
QObject * parent
Definition: qobject.h:92
QPointer< QAction > menuAction
Definition: qtoolbutton.cpp:82
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
const QRect availableGeometry(int screen=-1) const
The QToolButton class provides a quick-access button to commands or options, usually used inside a QT...
Definition: qtoolbutton.h:59
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ updateHoverControl()

bool QToolButtonPrivate::updateHoverControl ( const QPoint pos)

Definition at line 617 of file qtoolbutton.cpp.

618 {
619  Q_Q(QToolButton);
620  QRect lastHoverRect = hoverRect;
621  QStyle::SubControl lastHoverControl = hoverControl;
622  bool doesHover = q->testAttribute(Qt::WA_Hover);
623  if (lastHoverControl != newHoverControl(pos) && doesHover) {
624  q->update(lastHoverRect);
625  q->update(hoverRect);
626  return true;
627  }
628  return !doesHover;
629 }
QStyle::SubControl hoverControl
Definition: qtoolbutton.cpp:80
SubControl
This enum describes the available sub controls.
Definition: qstyle.h:402
QStyle::SubControl newHoverControl(const QPoint &pos)
#define Q_Q(Class)
Definition: qglobal.h:2483
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QToolButton class provides a quick-access button to commands or options, usually used inside a QT...
Definition: qtoolbutton.h:59

Properties

◆ actionsCopy

QList<QAction *> QToolButtonPrivate::actionsCopy

Definition at line 97 of file qtoolbutton.cpp.

◆ arrowType

Qt::ArrowType QToolButtonPrivate::arrowType

Definition at line 85 of file qtoolbutton.cpp.

◆ autoRaise

uint QToolButtonPrivate::autoRaise

Definition at line 91 of file qtoolbutton.cpp.

◆ buttonPressed

uint QToolButtonPrivate::buttonPressed

Definition at line 89 of file qtoolbutton.cpp.

◆ defaultAction

QAction* QToolButtonPrivate::defaultAction

Definition at line 93 of file qtoolbutton.cpp.

Referenced by hasMenu().

◆ delay

int QToolButtonPrivate::delay

Definition at line 84 of file qtoolbutton.cpp.

◆ hoverControl

QStyle::SubControl QToolButtonPrivate::hoverControl

Definition at line 80 of file qtoolbutton.cpp.

◆ hoverRect

QRect QToolButtonPrivate::hoverRect

Definition at line 81 of file qtoolbutton.cpp.

◆ menuAction

QPointer<QAction> QToolButtonPrivate::menuAction

Definition at line 82 of file qtoolbutton.cpp.

Referenced by hasMenu().

◆ menuButtonDown

uint QToolButtonPrivate::menuButtonDown

Definition at line 90 of file qtoolbutton.cpp.

◆ popupMode

QToolButton::ToolButtonPopupMode QToolButtonPrivate::popupMode

Definition at line 87 of file qtoolbutton.cpp.

◆ popupTimer

QBasicTimer QToolButtonPrivate::popupTimer

Definition at line 83 of file qtoolbutton.cpp.

◆ repeat

uint QToolButtonPrivate::repeat

Definition at line 92 of file qtoolbutton.cpp.

◆ toolButtonStyle

Qt::ToolButtonStyle QToolButtonPrivate::toolButtonStyle

Definition at line 86 of file qtoolbutton.cpp.


The documentation for this class was generated from the following file: