CopperSpice API  1.9.2
QToolBar Class Reference

Provides a movable panel that contains a set of controls. More...

Inheritance diagram for QToolBar:
QWidget QObject QPaintDevice

Public Signals

void actionTriggered (QAction *action)
 
void allowedAreasChanged (Qt::ToolBarAreas allowedAreas)
 
void iconSizeChanged (const QSize &iconSize)
 
void movableChanged (bool movable)
 
void orientationChanged (Qt::Orientation orientation)
 
void toolButtonStyleChanged (Qt::ToolButtonStyle toolButtonStyle)
 
void topLevelChanged (bool topLevel)
 
void visibilityChanged (bool visible)
 
- Public Signals inherited from QWidget
void customContextMenuRequested (const QPoint &pos)
 
void windowIconChanged (const QIcon &icon)
 
void windowIconTextChanged (const QString &iconText)
 
void windowTitleChanged (const QString &title)
 
- Public Signals inherited from QObject
void destroyed (QObject *obj=nullptr)
 
void objectNameChanged (const QString &objectName)
 

Public Slots

void setIconSize (const QSize &iconSize)
 
void setToolButtonStyle (Qt::ToolButtonStyle toolButtonStyle)
 
- Public Slots inherited from QWidget
bool close ()
 
void hide ()
 
void lower ()
 
void raise ()
 
void repaint ()
 
void setDisabled (bool disable)
 
void setEnabled (bool enable)
 
void setFocus ()
 
void setHidden (bool hidden)
 
void setStyleSheet (const QString &styleSheet)
 
virtual void setVisible (bool visible)
 
void setWindowModified (bool modified)
 
void setWindowTitle (const QString &title)
 
void show ()
 
void showFullScreen ()
 
void showMaximized ()
 
void showMinimized ()
 
void showNormal ()
 
void update ()
 
- Public Slots inherited from QObject
void deleteLater ()
 

Public Methods

 QToolBar (const QString &title, QWidget *parent=nullptr)
 
 QToolBar (QWidget *parent=nullptr)
 
 ~QToolBar ()
 
QActionactionAt (const QPoint &p) const
 
QActionactionAt (int x, int y) const
 
QRect actionGeometry (QAction *action) const
 
QActionaddAction (const QIcon &icon, const QString &text)
 
template<typename Func1 >
QActionaddAction (const QIcon &icon, const QString &text, const QObject *context, Func1 slot)
 
QActionaddAction (const QIcon &icon, const QString &text, const QObject *receiver, const QString &member)
 
template<typename Func1 >
QActionaddAction (const QIcon &icon, const QString &text, Func1 slot)
 
QActionaddAction (const QString &text)
 
template<typename Func1 >
QActionaddAction (const QString &text, const QObject *context, Func1 slot)
 
QActionaddAction (const QString &text, const QObject *receiver, const QString &member)
 
template<typename Func1 >
QActionaddAction (const QString &text, Func1 slot)
 
void addAction (QAction *action)
 
QActionaddSeparator ()
 
QActionaddWidget (QWidget *widget)
 
Qt::ToolBarAreas allowedAreas () const
 
void clear ()
 
QSize iconSize () const
 
QActioninsertSeparator (QAction *before)
 
QActioninsertWidget (QAction *before, QWidget *widget)
 
bool isAreaAllowed (Qt::ToolBarArea area) const
 
bool isFloatable () const
 
bool isFloating () const
 
bool isMovable () const
 
Qt::Orientation orientation () const
 
void setAllowedAreas (Qt::ToolBarAreas areas)
 
void setFloatable (bool floatable)
 
void setMovable (bool movable)
 
void setOrientation (Qt::Orientation orientation)
 
QActiontoggleViewAction () const
 
Qt::ToolButtonStyle toolButtonStyle () const
 
QWidgetwidgetForAction (QAction *action) const
 
- Public Methods inherited from QWidget
 QWidget (QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::EmptyFlag)
 
 ~QWidget ()
 
bool acceptDrops () const
 
QString accessibleDescription () const
 
QString accessibleName () const
 
QList< QAction * > actions () const
 
void activateWindow ()
 
void addAction (QAction *action)
 
void addActions (const QList< QAction * > &actions)
 
void adjustSize ()
 
bool autoFillBackground () const
 
QPalette::ColorRole backgroundRole () const
 
QBackingStorebackingStore () const
 
QSize baseSize () const
 
QWidget * childAt (const QPoint &position) const
 
QWidget * childAt (int x, int y) const
 
QRect childrenRect () const
 
QRegion childrenRegion () const
 
void clearFocus ()
 
void clearMask ()
 
QMargins contentsMargins () const
 
QRect contentsRect () const
 
Qt::ContextMenuPolicy contextMenuPolicy () const
 
QCursor cursor () const
 
WId effectiveWinId () const
 
void ensurePolished () const
 
Qt::FocusPolicy focusPolicy () const
 
QWidget * focusProxy () const
 
QWidget * focusWidget () const
 
const QFontfont () const
 
QFontInfo fontInfo () const
 
QFontMetrics fontMetrics () const
 
QPalette::ColorRole foregroundRole () const
 
QRect frameGeometry () const
 
QSize frameSize () const
 
const QRectgeometry () const
 
void getContentsMargins (int *left, int *top, int *right, int *bottom) const
 
QPixmap grab (const QRect &rectangle=QRect (QPoint (0, 0), QSize (-1,-1)))
 
void grabGesture (Qt::GestureType gestureType, Qt::GestureFlags flags=Qt::GestureFlags ())
 
void grabKeyboard ()
 
void grabMouse ()
 
void grabMouse (const QCursor &cursor)
 
int grabShortcut (const QKeySequence &key, Qt::ShortcutContext context=Qt::WindowShortcut)
 
QGraphicsEffectgraphicsEffect () const
 
QGraphicsProxyWidgetgraphicsProxyWidget () const
 
bool hasEditFocus () const
 
bool hasFocus () const
 
virtual bool hasHeightForWidth () const
 
bool hasMouseTracking () const
 
int height () const
 
virtual int heightForWidth (int width) const
 
Qt::InputMethodHints inputMethodHints () const
 
virtual QVariant inputMethodQuery (Qt::InputMethodQuery query) const
 
void insertAction (QAction *before, QAction *action)
 
void insertActions (QAction *before, QList< QAction * > actions)
 
bool isActiveWindow () const
 
bool isAncestorOf (const QWidget *child) const
 
bool isEnabled () const
 
bool isEnabledTo (const QWidget *parent) const
 
bool isEnabledToTLW () const
 
bool isFullScreen () const
 
bool isHidden () const
 
bool isMaximized () const
 
bool isMinimized () const
 
bool isModal () const
 
bool isTopLevel () const
 
bool isVisible () const
 
bool isVisibleTo (const QWidget *parent) const
 
bool isWindow () const
 
bool isWindowModified () const
 
QLayoutlayout () const
 
Qt::LayoutDirection layoutDirection () const
 
QLocale locale () const
 
QPoint mapFrom (const QWidget *parent, const QPoint &pos) const
 
QPoint mapFromGlobal (const QPoint &pos) const
 
QPoint mapFromParent (const QPoint &pos) const
 
QPoint mapTo (const QWidget *parent, const QPoint &pos) const
 
QPoint mapToGlobal (const QPoint &pos) const
 
QPoint mapToParent (const QPoint &pos) const
 
QRegion mask () const
 
int maximumHeight () const
 
QSize maximumSize () const
 
int maximumWidth () const
 
int minimumHeight () const
 
QSize minimumSize () const
 
virtual QSize minimumSizeHint () const
 
int minimumWidth () const
 
void move (const QPoint &point)
 
void move (int x, int y)
 
QWidget * nativeParentWidget () const
 
QWidget * nextInFocusChain () const
 
QRect normalGeometry () const
 
void overrideWindowFlags (Qt::WindowFlags flags)
 
QPaintEnginepaintEngine () const override
 
const QPalettepalette () const
 
QWidget * parentWidget () const
 
QPoint pos () const
 
QWidget * previousInFocusChain () const
 
QRect rect () const
 
void releaseKeyboard ()
 
void releaseMouse ()
 
void releaseShortcut (int id)
 
void removeAction (QAction *action)
 
void render (QPaintDevice *target, const QPoint &targetOffset=QPoint (), const QRegion &sourceRegion=QRegion (), RenderFlags renderFlags=RenderFlags (DrawWindowBackground|DrawChildren))
 
void render (QPainter *painter, const QPoint &targetOffset=QPoint (), const QRegion &sourceRegion=QRegion (), RenderFlags renderFlags=RenderFlags (DrawWindowBackground|DrawChildren))
 
void repaint (const QRect &rect)
 
void repaint (const QRegion &region)
 
void repaint (int x, int y, int w, int h)
 
void resize (const QSize &size)
 
void resize (int w, int h)
 
bool restoreGeometry (const QByteArray &geometry)
 
QByteArray saveGeometry () const
 
void scroll (int dx, int dy)
 
void scroll (int dx, int dy, const QRect &rect)
 
void setAcceptDrops (bool on)
 
void setAccessibleDescription (const QString &description)
 
void setAccessibleName (const QString &name)
 
void setAttribute (Qt::WidgetAttribute attribute, bool enable=true)
 
void setAutoFillBackground (bool enable)
 
void setBackgroundRole (QPalette::ColorRole role)
 
void setBaseSize (const QSize &size)
 
void setBaseSize (int basew, int baseh)
 
void setContentsMargins (const QMargins &margins)
 
void setContentsMargins (int left, int top, int right, int bottom)
 
void setContextMenuPolicy (Qt::ContextMenuPolicy policy)
 
void setCursor (const QCursor &cursor)
 
void setEditFocus (bool enable)
 
void setFixedHeight (int h)
 
void setFixedSize (const QSize &size)
 
void setFixedSize (int w, int h)
 
void setFixedWidth (int w)
 
void setFocus (Qt::FocusReason reason)
 
void setFocusPolicy (Qt::FocusPolicy policy)
 
void setFocusProxy (QWidget *widget)
 
void setFont (const QFont &font)
 
void setForegroundRole (QPalette::ColorRole role)
 
void setGeometry (const QRect &rect)
 
void setGeometry (int x, int y, int w, int h)
 
void setGraphicsEffect (QGraphicsEffect *effect)
 
void setInputMethodHints (Qt::InputMethodHints hints)
 
void setLayout (QLayout *layout)
 
void setLayoutDirection (Qt::LayoutDirection direction)
 
void setLocale (const QLocale &locale)
 
void setMask (const QBitmap &bitmap)
 
void setMask (const QRegion &region)
 
void setMaximumHeight (int maxh)
 
void setMaximumSize (const QSize &size)
 
void setMaximumSize (int maxw, int maxh)
 
void setMaximumWidth (int maxw)
 
void setMinimumHeight (int minh)
 
void setMinimumSize (const QSize &size)
 
void setMinimumSize (int minw, int minh)
 
void setMinimumWidth (int minw)
 
void setMouseTracking (bool enable)
 
void setPalette (const QPalette &palette)
 
void setParent (QWidget *parent)
 
void setParent (QWidget *parent, Qt::WindowFlags flags)
 
void setShortcutAutoRepeat (int id, bool enable=true)
 
void setShortcutEnabled (int id, bool enable=true)
 
void setSizeIncrement (const QSize &size)
 
void setSizeIncrement (int w, int h)
 
void setSizePolicy (QSizePolicy policy)
 
void setSizePolicy (QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical)
 
void setStatusTip (const QString &data)
 
void setStyle (QStyle *style)
 
void setToolTip (const QString &data)
 
void setToolTipDuration (int msec)
 
void setUpdatesEnabled (bool enable)
 
void setWhatsThis (const QString &str)
 
void setWindowFilePath (const QString &filePath)
 
void setWindowFlags (Qt::WindowFlags flags)
 
void setWindowIcon (const QIcon &icon)
 
void setWindowModality (Qt::WindowModality windowModality)
 
void setWindowOpacity (qreal level)
 
void setWindowRole (const QString &role)
 
void setWindowState (Qt::WindowStates windowState)
 
QSize size () const
 
virtual QSize sizeHint () const
 
QSize sizeIncrement () const
 
QSizePolicy sizePolicy () const
 
void stackUnder (QWidget *widget)
 
QString statusTip () const
 
QStylestyle () const
 
QString styleSheet () const
 
bool testAttribute (Qt::WidgetAttribute attribute) const
 
QString toolTip () const
 
int toolTipDuration () const
 
QWidget * topLevelWidget () const
 
bool underMouse () const
 
void ungrabGesture (Qt::GestureType gestureType)
 
void unsetCursor ()
 
void unsetLayoutDirection ()
 
void unsetLocale ()
 
void update (const QRect &rect)
 
void update (const QRegion &region)
 
void update (int x, int y, int w, int h)
 
void updateGeometry ()
 
bool updatesEnabled () const
 
QRegion visibleRegion () const
 
QString whatsThis () const
 
int width () const
 
QWidget * window () const
 
QString windowFilePath () const
 
Qt::WindowFlags windowFlags () const
 
QWindowwindowHandle () const
 
QIcon windowIcon () const
 
Qt::WindowModality windowModality () const
 
qreal windowOpacity () const
 
QString windowRole () const
 
Qt::WindowStates windowState () const
 
QString windowTitle () const
 
Qt::WindowType windowType () const
 
WId winId () const
 
int x () const
 
int y () const
 
- Public Methods inherited from QObject
 QObject (QObject *parent=nullptr)
 
 ~QObject ()
 
bool blockSignals (bool block)
 
const QList< QObject * > & children () const
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QStringdynamicPropertyNames () const
 
virtual bool event (QEvent *event)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
template<typename T >
findChild (const QString &childName=QString ()) const
 
template<class T >
QList< T > findChildren (const QRegularExpression &regExp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<class T >
QList< T > findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
bool inherits (const QString &className) const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const
 
bool isWindowType () const
 
void killTimer (int id)
 
const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const
 
QObject * parent () const
 
template<class T = QVariant>
property (const QString &name) const
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const QString &name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
QThreadthread () const
 
- Public Methods inherited from QPaintDevice
virtual ~QPaintDevice ()
 
int colorCount () const
 
int depth () const
 
int devicePixelRatio () const
 
qreal devicePixelRatioF () const
 
int height () const
 
int heightMM () const
 
int logicalDpiX () const
 
int logicalDpiY () const
 
bool paintingActive () const
 
int physicalDpiX () const
 
int physicalDpiY () const
 
int width () const
 
int widthMM () const
 

Protected Methods

void actionEvent (QActionEvent *event) override
 
void changeEvent (QEvent *event) override
 
bool event (QEvent *event) override
 
void paintEvent (QPaintEvent *event) override
 
- Protected Methods inherited from QWidget
virtual void closeEvent (QCloseEvent *event)
 
virtual void contextMenuEvent (QContextMenuEvent *event)
 
void create (WId window=0, bool initializeWindow=true, bool destroyOldWindow=true)
 
void destroy (bool destroyWindow=true, bool destroySubWindows=true)
 
virtual void dragEnterEvent (QDragEnterEvent *event)
 
virtual void dragLeaveEvent (QDragLeaveEvent *event)
 
virtual void dragMoveEvent (QDragMoveEvent *event)
 
virtual void dropEvent (QDropEvent *event)
 
virtual void enterEvent (QEvent *event)
 
bool event (QEvent *event) override
 
virtual void focusInEvent (QFocusEvent *event)
 
bool focusNextChild ()
 
virtual bool focusNextPrevChild (bool next)
 
virtual void focusOutEvent (QFocusEvent *event)
 
bool focusPreviousChild ()
 
virtual void hideEvent (QHideEvent *event)
 
void initPainter (QPainter *painter) const override
 
virtual void inputMethodEvent (QInputMethodEvent *event)
 
virtual void keyPressEvent (QKeyEvent *event)
 
virtual void keyReleaseEvent (QKeyEvent *event)
 
virtual void leaveEvent (QEvent *event)
 
int metric (PaintDeviceMetric metric) const override
 
virtual void mouseDoubleClickEvent (QMouseEvent *event)
 
virtual void mouseMoveEvent (QMouseEvent *event)
 
virtual void mousePressEvent (QMouseEvent *event)
 
virtual void mouseReleaseEvent (QMouseEvent *event)
 
virtual void moveEvent (QMoveEvent *event)
 
virtual bool nativeEvent (const QByteArray &eventType, void *message, long *result)
 
virtual void resizeEvent (QResizeEvent *event)
 
virtual void showEvent (QShowEvent *event)
 
virtual void tabletEvent (QTabletEvent *event)
 
virtual void wheelEvent (QWheelEvent *event)
 
- Protected Methods inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signalMethod) const
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signalMethod) const
 
bool isSignalConnected (const QMetaMethod &signalMethod) const
 
int receivers (const QString &signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 
- Protected Methods inherited from QPaintDevice
 QPaintDevice ()
 

Properties

 allowedAreas
 
 floatable
 
 floating
 
 iconSize
 
 movable
 
 orientation
 
 toolButtonStyle
 
- Properties inherited from QWidget
 acceptDrops
 
 accessibleDescription
 
 accessibleName
 
 autoFillBackground
 
 baseSize
 
 childrenRect
 
 childrenRegion
 
 contextMenuPolicy
 
 cursor
 
 enabled
 
 focus
 
 focusPolicy
 
 font
 
 frameGeometry
 
 frameSize
 
 fullScreen
 
 geometry
 
 height
 
 inputMethodHints
 
 isActiveWindow
 
 layoutDirection
 
 locale
 
 maximized
 
 maximumHeight
 
 maximumSize
 
 maximumWidth
 
 minimized
 
 minimumHeight
 
 minimumSize
 
 minimumSizeHint
 
 minimumWidth
 
 modal
 
 mouseTracking
 
 normalGeometry
 
 palette
 
 pos
 
 rect
 
 size
 
 sizeHint
 
 sizeIncrement
 
 sizePolicy
 
 statusTip
 
 styleSheet
 
 toolTip
 
 updatesEnabled
 
 visible
 
 whatsThis
 
 width
 
 windowFilePath
 
 windowFlags
 
 windowIcon
 
 windowIconText
 
 windowModality
 
 windowModified
 
 windowOpacity
 
 windowTitle
 
 x
 
 y
 
- Properties inherited from QObject
 objectName
 

Friends

class QMainWindow
 

Additional Inherited Members

- Public Typedefs inherited from QWidget
using RenderFlags = QFlags< RenderFlag >
 
- Public Types inherited from QWidget
enum  RenderFlag
 
- Public Types inherited from QPaintDevice
enum  PaintDeviceMetric
 
- Static Public Methods inherited from QWidget
static QWidget * createWindowContainer (QWindow *window, QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::EmptyFlag)
 
static QWidget * find (WId id)
 
static QWidget * keyboardGrabber ()
 
static QWidget * mouseGrabber ()
 
static void setTabOrder (QWidget *firstWidget, QWidget *secondWidget)
 
- Static Public Methods inherited from QObject
static bool connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ())
 
static bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...))
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod)
 
static QMetaObjectstaticMetaObject ()
 
static QString tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >())
 
- Protected Slots inherited from QWidget
void updateMicroFocus ()
 

Detailed Description

The QToolBar class provides a movable panel that contains a set of controls.

Toolbar buttons are added by adding actions, using addAction() or insertAction(). Groups of buttons can be separated using addSeparator() or insertSeparator(). If a toolbar button is not appropriate, a widget can be inserted instead using addWidget() or insertWidget(); examples of suitable widgets are QSpinBox, QDoubleSpinBox, and QComboBox. When a toolbar button is pressed it emits the actionTriggered() signal.

A toolbar can be fixed in place in a particular area (e.g. at the top of the window), or it can be movable (isMovable()) between toolbar areas; see allowedAreas() and isAreaAllowed().

When a toolbar is resized in such a way that it is too small to show all the items it contains, an extension button will appear as the last item in the toolbar. Pressing the extension button will pop up a menu containing the items that does not currently fit in the toolbar.

When a QToolBar is not a child of a QMainWindow, it loses the ability to populate the extension pop up with widgets added to the toolbar using addWidget(). Please use widget actions created by inheriting QWidgetAction and implementing QWidgetAction::createWidget() instead.

See also
QToolButton, QMenu, QAction

Constructor & Destructor Documentation

QToolBar::QToolBar ( const QString title,
QWidget parent = nullptr 
)
explicit

Constructs a QToolBar with the given parent.

The given window title identifies the toolbar and is shown in the context menu provided by QMainWindow.

See also
setWindowTitle()
QToolBar::QToolBar ( QWidget parent = nullptr)
explicit

Constructs a QToolBar with the given parent.

QToolBar::~QToolBar ( )

Destroys the toolbar.

Method Documentation

QAction * QToolBar::actionAt ( const QPoint p) const

Returns the action at point p. This method returns a nullptr if no action was found.

See also
QWidget::childAt()
QAction * QToolBar::actionAt ( int  x,
int  y 
) const
inline

Returns the action at the point x, y. This method returns a nullptr if no action was found.

void QToolBar::actionEvent ( QActionEvent event)
overrideprotectedvirtual

This event handler is called with the given event whenever the widget's actions are changed.

See also
addAction(), insertAction(), removeAction(), actions(), QActionEvent

Reimplemented from QWidget::actionEvent()

QRect QToolBar::actionGeometry ( QAction action) const

Returns the geometry of the toolbar item associated with the given action or an invalid QRect if no matching item is found.

void QToolBar::actionTriggered ( QAction action)
signal

This signal is emitted when an action in this toolbar is triggered. This happens when the action's tool button is pressed or when the action is triggered in some other way outside the toolbar. The parameter holds the triggered action.

QAction * QToolBar::addAction ( const QIcon icon,
const QString text 
)

Creates a new action with the given icon and text. This action is added to the end of the toolbar.

template<typename Func1 >
QAction * QToolBar::addAction ( const QIcon icon,
const QString text,
const QObject context,
Func1  slot 
)

Creates a new action with the given icon and text. This action is added to the end of the toolbar. The action's triggered() signal is connected to the slot.

If context is destroyed, the slot will not be called.

QAction * QToolBar::addAction ( const QIcon icon,
const QString text,
const QObject receiver,
const QString member 
)

Creates a new action with the given icon and text. This action is added to the end of the toolbar. The QAction::triggered() signal is connected to member in receiver.

template<typename Func1 >
QAction * QToolBar::addAction ( const QIcon icon,
const QString text,
Func1  slot 
)

Creates a new action with the given icon and text. This action is added to the end of the toolbar. The action's triggered() signal is connected to the slot.

Creates a new action with the given actionIcon and text. This action is added to the end of the toolbar. The QAction::triggered() signal is connected to the function object slot.

QAction * QToolBar::addAction ( const QString text)

Creates a new action with the given text. This action is added to the end of the toolbar.

template<typename Func1 >
QAction * QToolBar::addAction ( const QString text,
const QObject context,
Func1  slot 
)

Creates a new action with the given text. This action is added to the end of the toolbar. The action's triggered() signal is connected to the slot.

If context is destroyed, the slot will not be called.

QAction * QToolBar::addAction ( const QString text,
const QObject receiver,
const QString member 
)

Creates a new action with the given text. This action is added to the end of the toolbar. The QAction::triggered() signal is connected to member in receiver.

template<typename Func1 >
QAction * QToolBar::addAction ( const QString text,
Func1  slot 
)
inline

Creates a new action with the given text. This action is added to the end of the toolbar. The action's triggered() signal is connected to the slot.

void QWidget::addAction ( QAction action)
using

Appends action to the list of existing actions available for this widget. A QAction list is typically used to create a context QMenu, however it can be represented in different ways depending on the widget.

A QWidget should only have one of each action. Adding an action which already exists will not cause the same action to be in the widget multiple times. The ownership of action is not transferred to this QWidget.

See also
removeAction(), insertAction(), actions(), QMenu
QAction * QToolBar::addSeparator ( )

Adds a separator to the end of the toolbar.

See also
insertSeparator()
QAction * QToolBar::addWidget ( QWidget widget)

Adds the given widget to the toolbar as the toolbar's last item.

The toolbar takes ownership of widget.

If you add a QToolButton with this method, the tools bar's Qt::ToolButtonStyle will not be respected.

Note
You should use QAction::setVisible() to change the visibility of the widget. Using QWidget::setVisible(), QWidget::show() and QWidget::hide() does not work.
See also
insertWidget()
Qt::ToolBarAreas QToolBar::allowedAreas ( ) const

Returns the value of the property.

void QToolBar::allowedAreasChanged ( Qt::ToolBarAreas  allowedAreas)
signal

This signal is emitted when the collection of allowed areas for the toolbar is changed. The new areas in which the toolbar can be positioned are specified by allowedAreas.

See also
allowedAreas
void QToolBar::changeEvent ( QEvent event)
overrideprotectedvirtual

This event handler can be reimplemented to handle state changes. The state being changed in this event can be retrieved through the event supplied.

Reimplemented from QWidget::changeEvent()

void QToolBar::clear ( )

Removes all actions from the toolbar.

See also
removeAction()
bool QToolBar::event ( QEvent event)
overrideprotected

Reimplemented from QWidget::event()

QSize QToolBar::iconSize ( ) const

Returns the value of the property.

void QToolBar::iconSizeChanged ( const QSize iconSize)
signal

This signal is emitted when the icon size is changed. The iconSize parameter holds the toolbar's new icon size.

See also
QToolBar::iconSize, QMainWindow::iconSize
QAction * QToolBar::insertSeparator ( QAction before)

Inserts a separator into the toolbar in front of the toolbar item associated with the before action.

See also
addSeparator()
QAction * QToolBar::insertWidget ( QAction before,
QWidget widget 
)

Inserts the given widget in front of the toolbar item associated with the before action. Use QAction::setVisible() to change the visibility of the widget. Using QWidget::setVisible(), QWidget::show() and QWidget::hide() does not work.

See also
addWidget()
bool QToolBar::isAreaAllowed ( Qt::ToolBarArea  area) const
inline

Returns true if this toolbar is dockable in the given area, otherwise returns false.

bool QToolBar::isFloatable ( ) const

Returns the value of the property.

bool QToolBar::isFloating ( ) const

Returns the value of the property.

bool QToolBar::isMovable ( ) const

Returns the value of the property.

void QToolBar::movableChanged ( bool  movable)
signal

This signal is emitted when the toolbar becomes movable or fixed. If the toolbar can be moved then movable is true, otherwise it is false.

See also
QToolBar::movable
Qt::Orientation QToolBar::orientation ( ) const

Returns the value of the property.

void QToolBar::orientationChanged ( Qt::Orientation  orientation)
signal

This signal is emitted when the orientation of the toolbar changes. The new orientation is specified by the orientation given.

See also
orientation
void QToolBar::paintEvent ( QPaintEvent event)
overrideprotectedvirtual

This event handler can be reimplemented in a subclass to receive paint events passed in event. A paint event is a request to repaint all or part of a widget. It can happen for one of the following reasons.

  • repaint() or update() was invoked
  • widget was obscured and has now been uncovered
  • some other reason

Many widgets can simply repaint their entire surface when asked to, but some slow widgets need to optimize by painting only the requested region: QPaintEvent::region(). This speed optimization does not change the result, as painting is clipped to that region during event processing. QListView and QTableView do this, for example.

CopperSpice also tries to speed up painting by merging multiple paint events into one. When update() is called several times or the window system sends several paint events, CopperSpice merges these events into one event with a larger region (see QRegion::united()). The repaint() method does not permit this optimization, so we suggest using update() whenever possible.

When the paint event occurs, the update region has normally been erased, so you are painting on the widget's background. The background can be set using setBackgroundRole() and setPalette().

QWidget automatically double-buffers its painting, so there is no need to write double-buffering code in paintEvent() to avoid flicker.

For the X11 platform it is possible to toggle global double buffering by calling qt_x11_set_global_double_buffer().

extern void qt_x11_set_global_double_buffer(bool);
qt_x11_set_global_double_buffer(false);

Generally you should refrain from calling update() or repaint() inside a paintEvent(). For example, calling update() or repaint() on children inside a paintevent() results in undefined behavior; the child may or may not get a paint event.

Warning
If you are using a custom paint engine without the CopperSpice backingstore, Qt::WA_PaintOnScreen must be set. Otherwise, QWidget::paintEngine() will never be called; the backingstore will be used instead.
See also
event(), repaint(), update(), QPainter, QPixmap, QPaintEvent

Reimplemented from QWidget::paintEvent()

void QToolBar::setAllowedAreas ( Qt::ToolBarAreas  areas)

Sets the value of the property to areas.

void QToolBar::setFloatable ( bool  floatable)

Sets the value of the property to floatable.

void QToolBar::setIconSize ( const QSize iconSize)
slot

Sets the value of the property to iconSize.

void QToolBar::setMovable ( bool  movable)

Sets the value of the property to movable.

void QToolBar::setOrientation ( Qt::Orientation  orientation)

Sets the value of the property to orientation.

void QToolBar::setToolButtonStyle ( Qt::ToolButtonStyle  toolButtonStyle)
slot

Sets the value of the property to toolButtonStyle.

QAction * QToolBar::toggleViewAction ( ) const

Returns a checkable action that can be used to show or hide this toolbar. The action's text is set to the toolbar's window title.

See also
QAction::text, QWidget::windowTitle
Qt::ToolButtonStyle QToolBar::toolButtonStyle ( ) const

Returns the value of the property.

void QToolBar::toolButtonStyleChanged ( Qt::ToolButtonStyle  toolButtonStyle)
signal

This signal is emitted when the tool button style is changed. The toolButtonStyle parameter holds the toolbar's new tool button style.

See also
toolButtonStyle, QMainWindow::toolButtonStyle
void QToolBar::topLevelChanged ( bool  topLevel)
signal

This signal is emitted when the floating property changes. The topLevel parameter is true if the toolbar is now floating, otherwise it is false.

See also
isWindow()
void QToolBar::visibilityChanged ( bool  visible)
signal

This signal is emitted when the toolbar becomes visible (or invisible). This happens when the widget is hidden or shown.

QWidget * QToolBar::widgetForAction ( QAction action) const

Returns the widget associated with the specified action.

See also
addWidget()

Property Documentation

QToolBar::allowedAreas

This property holds areas where the toolbar may be placed. The default is Qt::AllToolBarAreas. This property only makes sense if the toolbar is in a QMainWindow.

See also
movable
PropertiesClass Methods
read allowedAreas
write setAllowedAreas
QToolBar::floatable

This property holds whether the toolbar can be dragged and dropped as an independent window. The default is true.

PropertiesClass Methods
read isFloatable
write setFloatable
QToolBar::floating

This property holds whether the toolbar is an independent window. By default, this property is true.

See also
QWidget::isWindow()
PropertiesClass Methods
read isFloating
QToolBar::iconSize

This property holds size of icons in the toolbar.

The default size is determined by the application's style and is derived from the QStyle::PM_ToolBarIconSize pixel metric. It is the maximum size an icon can have. Icons of smaller size will not be scaled up.

PropertiesClass Methods
read iconSize
write setIconSize
notify iconSizeChanged
QToolBar::movable

This property holds whether the user can move the toolbar within the toolbar area, or between toolbar areas. By default, this property is true. This property only makes sense if the toolbar is in a QMainWindow.

See also
QToolBar::allowedAreas
PropertiesClass Methods
read isMovable
write setMovable
QToolBar::orientation

This property holds the orientation of the toolbar. The default is Qt::Horizontal.

This property should not be modified when the toolbar is displayed on a QMainWindow. Instead, call QMainWindow::addToolBar() or QMainWindow::insertToolBar() to move a toolbar to another Qt::ToolBarArea.

PropertiesClass Methods
read orientation
write setOrientation
QToolBar::toolButtonStyle

This property defines the style of all tool buttons which are added as QActions. The default is Qt::ToolButtonIconOnly. If you add a QToolButton using addWidget() this button style is not supported.

PropertiesClass Methods
read toolButtonStyle
write setToolButtonStyle
notify toolButtonStyleChanged