QMacToolBar Class

The QMacToolBar class wraps the native NSToolbar class. More...

Header: #include <QMacToolBar>
qmake: QT += macextras
Since: Qt 5.3
Inherits: QObject

Public Functions

QMacToolBar(QObject *parent = nullptr)
QMacToolBar(const QString &identifier, QObject *parent = nullptr)
virtual ~QMacToolBar()
QMacToolBarItem *addAllowedItem(const QIcon &icon, const QString &text)
QMacToolBarItem *addAllowedStandardItem(QMacToolBarItem::StandardItem standardItem)
QMacToolBarItem *addItem(const QIcon &icon, const QString &text)
void addSeparator()
QMacToolBarItem *addStandardItem(QMacToolBarItem::StandardItem standardItem)
QList<QMacToolBarItem *> allowedItems()
void attachToWindow(QWindow *window)
void detachFromWindow()
QList<QMacToolBarItem *> items()
NSToolbar *nativeToolbar() const
void setAllowedItems(QList<QMacToolBarItem *> &allowedItems)
void setItems(QList<QMacToolBarItem *> &items)
  • 31 public functions inherited from QObject

Static Public Members

const QMetaObject staticMetaObject
  • 9 static public members inherited from QObject

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 2 signals inherited from QObject
  • 9 protected functions inherited from QObject

Detailed Description

The QMacToolBar class wraps the native NSToolbar class.

QMacToolBar provides a Qt-based API for NSToolBar. The toolbar displays one or more items. Each toolbar item has an icon and a text label.

The toolbar must be attached to a QWindow using the attachToWindow() method in order to be visible. The toolbar is attached to the native NSWindow and is displayed above the QWindow. QMacToolBar visibility follows window visibility.

Add items by calling addItem(). The toolbar has a customization menu which is available to the user from the toolbar context menu. Use addAllowedItem() to add items to the customization menu.

Usage: (QtWidgets)

QMacToolBar *toolBar = new QMacToolBar(this);
QMacToolBarItem *toolBarItem = toolBar->addItem(QIcon(), QStringLiteral("foo"));
connect(toolBarItem, SIGNAL(activated()), this, SLOT(fooClicked()));

this->window()->winId(); // create window->windowhandle()
toolBar->attachToWindow(this->window()->windowHandle());

See also QMacToolBarItem.

Member Function Documentation

QMacToolBar::QMacToolBar(QObject *parent = nullptr)

Default constructs an instance of QMacToolBar.

QMacToolBar::QMacToolBar(const QString &identifier, QObject *parent = nullptr)

Default constructs an instance of QMacToolBar.

[virtual] QMacToolBar::~QMacToolBar()

Destroys the instance of QMacToolBar. The destructor is virtual.

QMacToolBarItem *QMacToolBar::addAllowedItem(const QIcon &icon, const QString &text)

QMacToolBarItem *QMacToolBar::addAllowedStandardItem(QMacToolBarItem::StandardItem standardItem)

QMacToolBarItem *QMacToolBar::addItem(const QIcon &icon, const QString &text)

void QMacToolBar::addSeparator()

QMacToolBarItem *QMacToolBar::addStandardItem(QMacToolBarItem::StandardItem standardItem)

QList<QMacToolBarItem *> QMacToolBar::allowedItems()

See also setAllowedItems().

void QMacToolBar::attachToWindow(QWindow *window)

void QMacToolBar::detachFromWindow()

QList<QMacToolBarItem *> QMacToolBar::items()

See also setItems().

NSToolbar *QMacToolBar::nativeToolbar() const

void QMacToolBar::setAllowedItems(QList<QMacToolBarItem *> &allowedItems)

See also allowedItems().

void QMacToolBar::setItems(QList<QMacToolBarItem *> &items)

See also items().

© 2019 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.