QMainWindow Class
QMainWindow 提供应用程序的主窗口. 更多...
头文件: | #include <QMainWindow> |
qmake: | QT += widgets |
基类: | QWidget |
公有类型
enum | DockOption { AnimatedDocks, AllowNestedDocks, AllowTabbedDocks, ForceTabbedDocks, VerticalTabs, GroupedDragging } |
flags | DockOptions |
属性
|
|
公有函数
QMainWindow(QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags()) | |
~QMainWindow() | |
void | addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget) |
void | addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget, Qt::Orientation orientation) |
void | addToolBar(Qt::ToolBarArea area, QToolBar *toolbar) |
void | addToolBar(QToolBar *toolbar) |
QToolBar * | addToolBar(const QString &title) |
void | addToolBarBreak(Qt::ToolBarArea area = Qt::TopToolBarArea) |
QWidget * | centralWidget() const |
Qt::DockWidgetArea | corner(Qt::Corner corner) const |
virtual QMenu * | createPopupMenu() |
DockOptions | dockOptions() const |
Qt::DockWidgetArea | dockWidgetArea(QDockWidget *dockwidget) const |
bool | documentMode() const |
QSize | iconSize() const |
void | insertToolBar(QToolBar *before, QToolBar *toolbar) |
void | insertToolBarBreak(QToolBar *before) |
bool | isAnimated() const |
bool | isDockNestingEnabled() const |
QMenuBar * | menuBar() const |
QWidget * | menuWidget() const |
void | removeDockWidget(QDockWidget *dockwidget) |
void | removeToolBar(QToolBar *toolbar) |
void | removeToolBarBreak(QToolBar *before) |
void | resizeDocks(const QList<QDockWidget *> &docks, const QList<int> &sizes, Qt::Orientation orientation) |
bool | restoreDockWidget(QDockWidget *dockwidget) |
bool | restoreState(const QByteArray &state, int version = 0) |
QByteArray | saveState(int version = 0) const |
void | setCentralWidget(QWidget *widget) |
void | setCorner(Qt::Corner corner, Qt::DockWidgetArea area) |
void | setDockOptions(DockOptions options) |
void | setDocumentMode(bool enabled) |
void | setIconSize(const QSize &iconSize) |
void | setMenuBar(QMenuBar *menuBar) |
void | setMenuWidget(QWidget *menuBar) |
void | setStatusBar(QStatusBar *statusbar) |
void | setTabPosition(Qt::DockWidgetAreas areas, QTabWidget::TabPosition tabPosition) |
void | setTabShape(QTabWidget::TabShape tabShape) |
void | setToolButtonStyle(Qt::ToolButtonStyle toolButtonStyle) |
void | splitDockWidget(QDockWidget *first, QDockWidget *second, Qt::Orientation orientation) |
QStatusBar * | statusBar() const |
QTabWidget::TabPosition | tabPosition(Qt::DockWidgetArea area) const |
QTabWidget::TabShape | tabShape() const |
QList<QDockWidget *> | tabifiedDockWidgets(QDockWidget *dockwidget) const |
void | tabifyDockWidget(QDockWidget *first, QDockWidget *second) |
QWidget * | takeCentralWidget() |
Qt::ToolBarArea | toolBarArea(QToolBar *toolbar) const |
bool | toolBarBreak(QToolBar *toolbar) const |
Qt::ToolButtonStyle | toolButtonStyle() const |
bool | unifiedTitleAndToolBarOnMac() const |
- 214 个公有函数继承自 QWidget
- 32 个公有函数继承自 QObject
- 14 个公有函数继承自 QPaintDevice
公有槽函数
void | setAnimated(bool enabled) |
void | setDockNestingEnabled(bool enabled) |
void | setUnifiedTitleAndToolBarOnMac(bool set) |
信号
void | iconSizeChanged(const QSize &iconSize) |
void | tabifiedDockWidgetActivated(QDockWidget *dockWidget) |
void | toolButtonStyleChanged(Qt::ToolButtonStyle toolButtonStyle) |
重新实现的受保护函数
virtual void | contextMenuEvent(QContextMenuEvent *event) |
virtual bool | event(QEvent *event) |
- 35 个受保护的函数继承自 QWidget
- 9 个受保护的函数继承自 QObject
- 1 个受保护的函数继承自 QPaintDevice
其他继承的成员
- 1 个公有变量继承自 QObject
- 5 个静态公有成员继承自 QWidget
- 10 个静态公有成员继承自 QObject
- 35 个受保护的函数继承自 QWidget
- 9 个受保护的函数继承自 QObject
- 1 个受保护的函数继承自 QPaintDevice
- 1 个受保护的槽函数继承自 QWidget
- 2 个受保护的变量继承自 QObject
- 1 protected type inherited from QPaintDevice
详细描述
QMainWindow 提供应用程序的主窗口.
Qt主窗口框架
主窗口提供一个创建应用程序UI框架. Qt 提供 QMainWindow 和它的 关联类 管理主窗口. QMainWindow 对 QToolBar, QDockWidget, QMenuBar, QStatusBar 提供默认布局. 布局的中心区域可以添加任意 widget. 默认布局如下:
注意: 创建主窗口时, 你必须设置一个中心区域.
创建主窗口部件
中心widget是一个标准的QWidget, 如 QTextEdit 或 QGraphicsView. 你可以调用 setCentralWidget()
函数设置中心widget.
主窗口可以是单文档界面 (SDI), 也可以是多文档界面 (MDI). 你可以将 QMdiArea 作为主窗口创建MDI应用程序.
我们将举例说明如何创建和添加主窗口的各类部件.
创建菜单
Qt 的 QMenu 类实现菜单, QMainWindow 在 QMenuBar 中保存它们. QAction 加入菜单, 作为菜单项显示.
你可以调用 menuBar()
获取窗口的 QMenuBar, 然后调用 QMenuBar::addMenu() 加入新菜单.
QMainWindow 创建一个默认菜单栏, 你也可以调用 setMenuBar()
设置自定义菜单栏. 如果你实现一个自定义的菜单栏 (即., 没有使用 QMenuBar ), 你可以调用 setMenuWidget()
设置菜单栏.
下列示例展示如何创建菜单:
void MainWindow::createMenus() { fileMenu = menuBar()->addMenu(tr("&File")); fileMenu->addAction(newAct); fileMenu->addAction(openAct); fileMenu->addAction(saveAct);
主窗口接收到上下文菜单事件时, 你可以调用 createPopupMenu()
函数创建弹出式菜单. T停靠widgets和工具条的actions提供默认菜单. 你也可以重新实现 createPopupMenu()
创建自定义菜单.
创建工具条
QToolBar 实现工具条. 你可以调用 addToolBar()
向主窗口添加一个工具条.
你可以使用 Qt::ToolBarArea控制工具条的初始位置. 你可以调用 addToolBarBreak()
或 insertToolBarBreak()
插入分隔线将工具条分隔成不同的区域. 你也可以调用 QToolBar::setAllowedAreas() 和 QToolBar::setMovable() 限制工具条位置.
你可以调用 iconSize()
获取工具条的图片大小. 图片默认大小与平台相关; 你可以调用 setIconSize()
设置图片大小. 你可以调用 setToolButtonStyle()
更改工具条按钮的外观.
下列示例展示如何创建工具条:
void MainWindow::createToolBars() { fileToolBar = addToolBar(tr("File")); fileToolBar->addAction(newAct);
创建停靠widget
QDockWidget 实现停靠widget. 一个停靠widget是可以停靠在主窗体的窗口. 你可以调用 addDockWidget()
在主窗口添加停靠widget.
主窗口有四个停靠区域, 由 Qt::DockWidgetArea 标识: 左, 右, 上, 下. 你可以调用 setCorner()
设置QMainWindow的四个角由哪个停靠widget占据. 默认情况下, 每个区域有一个水平或垂直的停靠widget, 但是你也可以调用 setDockNestingEnabled()
开启多个停靠widget, 停靠widget可以放置在任意方向.
主窗口的顶部可以放两个停靠widget. 使用 QTabBar 选择显示哪个停靠widget.
下列代码展示如何在主窗口创建并添加停靠widget:
QDockWidget *dockWidget = new QDockWidget(tr("Dock Widget"), this); dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); dockWidget->setWidget(dockWidgetContents); addDockWidget(Qt::LeftDockWidgetArea, dockWidget);
状态栏
你可以调用 setStatusBar()
创建一个状态栏, 第一次调用 statusBar()
(这个函数会返回主窗口的状态栏) 会创建一个状态栏. 详见 QStatusBar.
存储状态
QMainWindow 可以调用 saveState()
存储布局状态; 之后调用 restoreState()
重置状态. 它可以存储工具条和停靠widgets的位置和大小 (相对主窗口大小).
参见 QMenuBar, QToolBar, QStatusBar, QDockWidget, Application Example, Dock Widgets Example, MDI Example, SDI Example, Menus Example.
成员类型
enum QMainWindow::DockOption
flags QMainWindow::DockOptions
This enum contains flags that specify the docking behavior of QMainWindow.
Constant | Value | Description |
---|---|---|
QMainWindow::AnimatedDocks | 0x01 | Identical to the animated property. |
QMainWindow::AllowNestedDocks | 0x02 | Identical to the dockNestingEnabled property. |
QMainWindow::AllowTabbedDocks | 0x04 | The user can drop one dock widget "on top" of another. The two widgets are stacked and a tab bar appears for selecting which one is visible. |
QMainWindow::ForceTabbedDocks | 0x08 | Each dock area contains a single stack of tabbed dock widgets. In other words, dock widgets cannot be placed next to each other in a dock area. If this option is set, AllowNestedDocks has no effect. |
QMainWindow::VerticalTabs | 0x10 | The two vertical dock areas on the sides of the main window show their tabs vertically. If this option is not set, all dock areas show their tabs at the bottom. Implies AllowTabbedDocks. See also setTabPosition(). |
QMainWindow::GroupedDragging | 0x20 | When dragging the titlebar of a dock, all the tabs that are tabbed with it are going to be dragged. Implies AllowTabbedDocks. Does not work well if some QDockWidgets have restrictions in which area they are allowed. (This enum value was added in Qt 5.6.) |
These options only control how dock widgets may be dropped in a QMainWindow. They do not re-arrange the dock widgets to conform with the specified options. For this reason they should be set before any dock widgets are added to the main window. Exceptions to this are the AnimatedDocks and VerticalTabs options, which may be set at any time.
This enum was introduced or modified in Qt 4.3.
The DockOptions type is a typedef for QFlags<DockOption>. It stores an OR combination of DockOption values.
属性
animated : bool
This property holds whether manipulating dock widgets and tool bars is animated
When a dock widget or tool bar is dragged over the main window, the main window adjusts its contents to indicate where the dock widget or tool bar will be docked if it is dropped. Setting this property causes QMainWindow to move its contents in a smooth animation. Clearing this property causes the contents to snap into their new positions.
By default, this property is set. It may be cleared if the main window contains widgets which are slow at resizing or repainting themselves.
Setting this property is identical to setting the AnimatedDocks option using setDockOptions().
This property was introduced in Qt 4.2.
访问函数:
bool | isAnimated() const |
void | setAnimated(bool enabled) |
dockNestingEnabled : bool
This property holds whether docks can be nested
If this property is false
, dock areas can only contain a single row (horizontal or vertical) of dock widgets. If this property is true
, the area occupied by a dock widget can be split in either direction to contain more dock widgets.
Dock nesting is only necessary in applications that contain a lot of dock widgets. It gives the user greater freedom in organizing their main window. However, dock nesting leads to more complex (and less intuitive) behavior when a dock widget is dragged over the main window, since there are more ways in which a dropped dock widget may be placed in the dock area.
Setting this property is identical to setting the AllowNestedDocks option using setDockOptions().
This property was introduced in Qt 4.2.
访问函数:
bool | isDockNestingEnabled() const |
void | setDockNestingEnabled(bool enabled) |
dockOptions : DockOptions
This property holds the docking behavior of QMainWindow
The default value is AnimatedDocks | AllowTabbedDocks.
This property was introduced in Qt 4.3.
访问函数:
DockOptions | dockOptions() const |
void | setDockOptions(DockOptions options) |
documentMode : bool
This property holds whether the tab bar for tabbed dockwidgets is set to document mode.
The default is false.
This property was introduced in Qt 4.5.
访问函数:
bool | documentMode() const |
void | setDocumentMode(bool enabled) |
iconSize : QSize
size of toolbar icons in this mainwindow.
The default is the default tool bar icon size of the GUI style. Note that the icons used must be at least of this size as the icons are only scaled down.
访问函数:
QSize | iconSize() const |
void | setIconSize(const QSize &iconSize) |
tabShape : QTabWidget::TabShape
This property holds the tab shape used for tabbed dock widgets.
The default is QTabWidget::Rounded.
This property was introduced in Qt 4.5.
访问函数:
QTabWidget::TabShape | tabShape() const |
void | setTabShape(QTabWidget::TabShape tabShape) |
参见 setTabPosition().
toolButtonStyle : Qt::ToolButtonStyle
style of toolbar buttons in this mainwindow.
To have the style of toolbuttons follow the system settings, set this property to Qt::ToolButtonFollowStyle. On Unix, the user settings from the desktop environment will be used. On other platforms, Qt::ToolButtonFollowStyle means icon only.
The default is Qt::ToolButtonIconOnly.
访问函数:
Qt::ToolButtonStyle | toolButtonStyle() const |
void | setToolButtonStyle(Qt::ToolButtonStyle toolButtonStyle) |
unifiedTitleAndToolBarOnMac : bool
This property holds whether the window uses the unified title and toolbar look on macOS
Note that the Qt 5 implementation has several limitations compared to Qt 4:
- Use in windows with OpenGL content is not supported. This includes QGLWidget and QOpenGLWidget.
- Using dockable or movable toolbars may result in painting errors and is not recommended
This property was introduced in Qt 5.2.
访问函数:
bool | unifiedTitleAndToolBarOnMac() const |
void | setUnifiedTitleAndToolBarOnMac(bool set) |
成员函数
QMainWindow::QMainWindow(QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags())
Constructs a QMainWindow with the given parent and the specified widget flags.
QMainWindow sets the Qt::Window flag itself, and will hence always be created as a top-level widget.
QMainWindow::~QMainWindow()
Destroys the main window.
void QMainWindow::addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget)
Adds the given dockwidget to the specified area.
void QMainWindow::addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget, Qt::Orientation orientation)
Adds dockwidget into the given area in the direction specified by the orientation.
void QMainWindow::addToolBar(Qt::ToolBarArea area, QToolBar *toolbar)
Adds the toolbar into the specified area in this main window. The toolbar is placed at the end of the current tool bar block (i.e. line). If the main window already manages toolbar then it will only move the toolbar to area.
参见 insertToolBar(), addToolBarBreak(), and insertToolBarBreak().
void QMainWindow::addToolBar(QToolBar *toolbar)
This is an overloaded function.
Equivalent of calling addToolBar(Qt::TopToolBarArea, toolbar)
QToolBar *QMainWindow::addToolBar(const QString &title)
This is an overloaded function.
Creates a QToolBar object, setting its window title to title, and inserts it into the top toolbar area.
参见 setWindowTitle().
void QMainWindow::addToolBarBreak(Qt::ToolBarArea area = Qt::TopToolBarArea)
Adds a toolbar break to the given area after all the other objects that are present.
QWidget *QMainWindow::centralWidget() const
Returns the central widget for the main window. This function returns zero if the central widget has not been set.
参见 setCentralWidget().
[virtual protected]
void QMainWindow::contextMenuEvent(QContextMenuEvent *event)
重新实现 QWidget::contextMenuEvent().
Qt::DockWidgetArea QMainWindow::corner(Qt::Corner corner) const
Returns the dock widget area that occupies the specified corner.
参见 setCorner().
[virtual]
QMenu *QMainWindow::createPopupMenu()
Returns a popup menu containing checkable entries for the toolbars and dock widgets present in the main window. If there are no toolbars and dock widgets present, this function returns a null pointer.
By default, this function is called by the main window when the user activates a context menu, typically by right-clicking on a toolbar or a dock widget.
If you want to create a custom popup menu, reimplement this function and return a newly-created popup menu. Ownership of the popup menu is transferred to the caller.
参见 addDockWidget(), addToolBar(), and menuBar().
Qt::DockWidgetArea QMainWindow::dockWidgetArea(QDockWidget *dockwidget) const
Returns the Qt::DockWidgetArea for dockwidget. If dockwidget has not been added to the main window, this function returns Qt::NoDockWidgetArea
.
参见 addDockWidget(), splitDockWidget(), and Qt::DockWidgetArea.
[virtual protected]
bool QMainWindow::event(QEvent *event)
重新实现 QObject::event().
[signal]
void QMainWindow::iconSizeChanged(const QSize &iconSize)
This signal is emitted when the size of the icons used in the window is changed. The new icon size is passed in iconSize.
You can connect this signal to other components to help maintain a consistent appearance for your application.
参见 setIconSize().
void QMainWindow::insertToolBar(QToolBar *before, QToolBar *toolbar)
Inserts the toolbar into the area occupied by the before toolbar so that it appears before it. For example, in normal left-to-right layout operation, this means that toolbar will appear to the left of the toolbar specified by before in a horizontal toolbar area.
参见 insertToolBarBreak(), addToolBar(), and addToolBarBreak().
void QMainWindow::insertToolBarBreak(QToolBar *before)
Inserts a toolbar break before the toolbar specified by before.
QMenuBar *QMainWindow::menuBar() const
Returns the menu bar for the main window. This function creates and returns an empty menu bar if the menu bar does not exist.
If you want all windows in a Mac application to share one menu bar, don't use this function to create it, because the menu bar created here will have this QMainWindow as its parent. Instead, you must create a menu bar that does not have a parent, which you can then share among all the Mac windows. Create a parent-less menu bar this way:
QMenuBar *menuBar = new QMenuBar(0);
参见 setMenuBar().
QWidget *QMainWindow::menuWidget() const
Returns the menu bar for the main window. This function returns null if a menu bar hasn't been constructed yet.
This function was introduced in Qt 4.2.
参见 setMenuWidget().
void QMainWindow::removeDockWidget(QDockWidget *dockwidget)
Removes the dockwidget from the main window layout and hides it. Note that the dockwidget is not deleted.
void QMainWindow::removeToolBar(QToolBar *toolbar)
Removes the toolbar from the main window layout and hides it. Note that the toolbar is not deleted.
void QMainWindow::removeToolBarBreak(QToolBar *before)
Removes a toolbar break previously inserted before the toolbar specified by before.
void QMainWindow::resizeDocks(const QList<QDockWidget *> &docks, const QList<int> &sizes, Qt::Orientation orientation)
Resizes the dock widgets in the list docks to the corresponding size in pixels from the list sizes. If orientation is Qt::Horizontal, adjusts the width, otherwise adjusts the height of the dock widgets. The sizes will be adjusted such that the maximum and the minimum sizes are respected and the QMainWindow itself will not be resized. Any additional/missing space is distributed amongst the widgets according to the relative weight of the sizes.
Example:
resizeDocks({blueWidget, yellowWidget}, {20 , 40}, Qt::Horizontal);
If the blue and the yellow widget are nested on the same level they will be resized such that the yellowWidget is twice as big as the blueWidget
If some widgets are grouped in tabs, only one widget per group should be specified. Widgets not in the list might be changed to repect the constraints.
This function was introduced in Qt 5.6.
bool QMainWindow::restoreDockWidget(QDockWidget *dockwidget)
Restores the state of dockwidget if it is created after the call to restoreState(). Returns true
if the state was restored; otherwise returns false
.
参见 restoreState() and saveState().
bool QMainWindow::restoreState(const QByteArray &state, int version = 0)
Restores the state of this mainwindow's toolbars and dockwidgets. Also restores the corner settings too. The version number is compared with that stored in state. If they do not match, the mainwindow's state is left unchanged, and this function returns false
; otherwise, the state is restored, and this function returns true
.
To restore geometry saved using QSettings, you can use code like this:
void MainWindow::readSettings() { QSettings settings("MyCompany", "MyApp"); restoreGeometry(settings.value("myWidget/geometry").toByteArray()); restoreState(settings.value("myWidget/windowState").toByteArray()); }
参见 saveState(), QWidget::saveGeometry(), QWidget::restoreGeometry(), and restoreDockWidget().
QByteArray QMainWindow::saveState(int version = 0) const
Saves the current state of this mainwindow's toolbars and dockwidgets. This includes the corner settings which can be set with setCorner(). The version number is stored as part of the data.
The objectName property is used to identify each QToolBar and QDockWidget. You should make sure that this property is unique for each QToolBar and QDockWidget you add to the QMainWindow
To restore the saved state, pass the return value and version number to restoreState().
To save the geometry when the window closes, you can implement a close event like this:
void MyMainWindow::closeEvent(QCloseEvent *event) { QSettings settings("MyCompany", "MyApp"); settings.setValue("geometry", saveGeometry()); settings.setValue("windowState", saveState()); QMainWindow::closeEvent(event); }
参见 restoreState(), QWidget::saveGeometry(), and QWidget::restoreGeometry().
void QMainWindow::setCentralWidget(QWidget *widget)
Sets the given widget to be the main window's central widget.
Note: QMainWindow takes ownership of the widget pointer and deletes it at the appropriate time.
参见 centralWidget().
void QMainWindow::setCorner(Qt::Corner corner, Qt::DockWidgetArea area)
Sets the given dock widget area to occupy the specified corner.
参见 corner().
void QMainWindow::setMenuBar(QMenuBar *menuBar)
Sets the menu bar for the main window to menuBar.
Note: QMainWindow takes ownership of the menuBar pointer and deletes it at the appropriate time.
参见 menuBar().
void QMainWindow::setMenuWidget(QWidget *menuBar)
Sets the menu bar for the main window to menuBar.
QMainWindow takes ownership of the menuBar pointer and deletes it at the appropriate time.
This function was introduced in Qt 4.2.
参见 menuWidget().
void QMainWindow::setStatusBar(QStatusBar *statusbar)
Sets the status bar for the main window to statusbar.
Setting the status bar to 0 will remove it from the main window. Note that QMainWindow takes ownership of the statusbar pointer and deletes it at the appropriate time.
参见 statusBar().
void QMainWindow::setTabPosition(Qt::DockWidgetAreas areas, QTabWidget::TabPosition tabPosition)
Sets the tab position for the given dock widget areas to the specified tabPosition. By default, all dock areas show their tabs at the bottom.
Note: The VerticalTabs dock option overrides the tab positions set by this method.
This function was introduced in Qt 4.5.
参见 tabPosition() and setTabShape().
void QMainWindow::splitDockWidget(QDockWidget *first, QDockWidget *second, Qt::Orientation orientation)
Splits the space covered by the first dock widget into two parts, moves the first dock widget into the first part, and moves the second dock widget into the second part.
The orientation specifies how the space is divided: A Qt::Horizontal split places the second dock widget to the right of the first; a Qt::Vertical split places the second dock widget below the first.
Note: if first is currently in a tabbed docked area, second will be added as a new tab, not as a neighbor of first. This is because a single tab can contain only one dock widget.
Note: The Qt::LayoutDirection influences the order of the dock widgets in the two parts of the divided area. When right-to-left layout direction is enabled, the placing of the dock widgets will be reversed.
参见 tabifyDockWidget(), addDockWidget(), and removeDockWidget().
QStatusBar *QMainWindow::statusBar() const
Returns the status bar for the main window. This function creates and returns an empty status bar if the status bar does not exist.
参见 setStatusBar().
QTabWidget::TabPosition QMainWindow::tabPosition(Qt::DockWidgetArea area) const
Returns the tab position for area.
Note: The VerticalTabs dock option overrides the tab positions returned by this function.
This function was introduced in Qt 4.5.
参见 setTabPosition() and tabShape().
[signal]
void QMainWindow::tabifiedDockWidgetActivated(QDockWidget *dockWidget)
This signal is emitted when the tabified dock widget is activated by selecting the tab. The activated dock widget is passed in dockWidget.
This function was introduced in Qt 5.8.
参见 tabifyDockWidget() and tabifiedDockWidgets().
QList<QDockWidget *> QMainWindow::tabifiedDockWidgets(QDockWidget *dockwidget) const
Returns the dock widgets that are tabified together with dockwidget.
This function was introduced in Qt 4.5.
参见 tabifyDockWidget().
void QMainWindow::tabifyDockWidget(QDockWidget *first, QDockWidget *second)
Moves second dock widget on top of first dock widget, creating a tabbed docked area in the main window.
参见 tabifiedDockWidgets().
QWidget *QMainWindow::takeCentralWidget()
Removes the central widget from this main window.
The ownership of the removed widget is passed to the caller.
This function was introduced in Qt 5.2.
Qt::ToolBarArea QMainWindow::toolBarArea(QToolBar *toolbar) const
Returns the Qt::ToolBarArea for toolbar. If toolbar has not been added to the main window, this function returns Qt::NoToolBarArea
.
参见 addToolBar(), addToolBarBreak(), and Qt::ToolBarArea.
bool QMainWindow::toolBarBreak(QToolBar *toolbar) const
Returns whether there is a toolbar break before the toolbar.
参见 addToolBarBreak() and insertToolBarBreak().
[signal]
void QMainWindow::toolButtonStyleChanged(Qt::ToolButtonStyle toolButtonStyle)
This signal is emitted when the style used for tool buttons in the window is changed. The new style is passed in toolButtonStyle.
You can connect this signal to other components to help maintain a consistent appearance for your application.
参见 setToolButtonStyle().