The QMacToolBar class wraps the native NSToolbar class. 更多...
头: | #include <QMacToolBar> |
qmake: | QT += macextras |
Since: | Qt 5.3 |
继承: | QObject |
QMacToolBar (QObject * parent = Q_NULLPTR) | |
QMacToolBar (const QString & 标识符 , QObject * parent = Q_NULLPTR) | |
~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 *> | 项 () |
NSToolbar * | nativeToolbar () const |
void | setAllowedItems (QList<QMacToolBarItem *> & allowedItems ) |
void | setItems (QList<QMacToolBarItem *> & 项 ) |
The QMacToolBar class wraps the native NSToolbar class.
QMacToolBar provides a Qt-based API for NSToolBar. The toolbar displays one or more 项 . Each toolbar item has an icon and a text label.
The toolbar must be attached to a QWindow 使用 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());
另请参阅 QMacToolBarItem .
构造 QMacToolBar 采用给定 parent
构造 QMacToolBar 采用给定 标识符 and parent . The identifier is used to uniquely identify the toolbar within the appliation, for example when autosaving the toolbar configuration.
Destroys the toolbar.
Add atoolbar item with icon and text to the toolbar customization menu.
Add a toolbar item with icon and text .
Add a toolbar separator item.
Returns the list oftoolbar items shown on the the toolbar customization menu.
另请参阅 setAllowedItems ().
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.
使用 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.
Detatches the toolbar from the current window.
Returns the list of the default toolbar items.
另请参阅 setItems ().
Returns the naitve NSTooolbar object.
Sets the list of toolbar items shown on the toolbar customization menu to allowedItems .
另请参阅 allowedItems ().
Sets the list of the default toolbar 项 .
另请参阅 项 ().