Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

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 * addItem(const QIcon &icon, const QString &text)
void addSeparator()
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)
  • 33 public functions inherited from QObject

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 2 signals inherited from QObject
  • 1 public variable inherited from QObject
  • 10 static public members inherited from QObject
  • 9 protected functions inherited from QObject
  • 2 protected variables 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)

Constructs a QMacToolBar with the given parent

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

Constructs a QMacToolBar with the given identifier and parent. The identifier is used to uniquely identify the toolbar within the appliation, for example when autosaving the toolbar configuration.

[virtual] QMacToolBar::~QMacToolBar()

Destroys the toolbar.

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

Add atoolbar item with icon and text to the toolbar customization menu.

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

Add a toolbar item with icon and text.

void QMacToolBar::addSeparator()

Add a toolbar separator item.

QList<QMacToolBarItem *> QMacToolBar::allowedItems()

Returns the list oftoolbar items shown on the the toolbar customization menu.

See also setAllowedItems().

void QMacToolBar::attachToWindow(QWindow *window)

Attaches the toolbar to window. The toolbar will be displayed at the top of the native window, under and attached to the title bar above the QWindow. The toolbar is displayed outside the QWidnow area.

Use QWidget::windowHandle() to get a QWindow pointer from a QWidget instance. At app startup the QWindow might not have been created yet, call QWidget::winId() to make sure it is.

void QMacToolBar::detachFromWindow()

Detatches the toolbar from the current window.

QList<QMacToolBarItem *> QMacToolBar::items()

Returns the list of the default toolbar items.

See also setItems().

NSToolbar *QMacToolBar::nativeToolbar() const

Returns the naitve NSTooolbar object.

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

Sets the list of toolbar items shown on the toolbar customization menu to allowedItems.

See also allowedItems().

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

Sets the list of the default toolbar items.

See also items().

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded