CopperSpice API
1.9.2
|
QMainWindow class provides the main GUI application window. More...
Public Typedefs | |
using | DockOptions = QFlags< DockOption > |
Public Typedefs inherited from QWidget | |
using | RenderFlags = QFlags< RenderFlag > |
Public Types | |
enum | DockOption |
Public Types inherited from QWidget | |
enum | RenderFlag |
Public Types inherited from QPaintDevice | |
enum | PaintDeviceMetric |
Public Signals | |
void | iconSizeChanged (const QSize &iconSize) |
void | toolButtonStyleChanged (Qt::ToolButtonStyle toolButtonStyle) |
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 | setAnimated (bool enabled) |
void | setDockNestingEnabled (bool enabled) |
void | setUnifiedTitleAndToolBarOnMac (bool set) |
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 | |
QMainWindow (QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::EmptyFlag) | |
~QMainWindow () | |
void | addDockWidget (Qt::DockWidgetArea area, QDockWidget *dockwidget) |
void | addDockWidget (Qt::DockWidgetArea area, QDockWidget *dockwidget, Qt::Orientation orientation) |
QToolBar * | addToolBar (const QString &title) |
void | addToolBar (Qt::ToolBarArea area, QToolBar *toolbar) |
void | addToolBar (QToolBar *toolbar) |
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 *location, QToolBar *newToolbar) |
void | insertToolBarBreak (QToolBar *location) |
bool | isAnimated () const |
bool | isDockNestingEnabled () const |
QMenuBar * | menuBar () const |
QWidget * | menuWidget () const |
void | removeDockWidget (QDockWidget *dockwidget) |
void | removeToolBar (QToolBar *toolbar) |
void | removeToolBarBreak (QToolBar *location) |
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 |
QList< QDockWidget * > | tabifiedDockWidgets (QDockWidget *dockwidget) const |
void | tabifyDockWidget (QDockWidget *first, QDockWidget *second) |
QTabWidget::TabPosition | tabPosition (Qt::DockWidgetArea area) const |
QTabWidget::TabShape | tabShape () const |
QWidget * | takeCentralWidget () |
Qt::ToolBarArea | toolBarArea (QToolBar *toolbar) const |
bool | toolBarBreak (QToolBar *toolbar) const |
Qt::ToolButtonStyle | toolButtonStyle () const |
bool | unifiedTitleAndToolBarOnMac () 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 |
QBackingStore * | backingStore () 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 QFont & | font () const |
QFontInfo | fontInfo () const |
QFontMetrics | fontMetrics () const |
QPalette::ColorRole | foregroundRole () const |
QRect | frameGeometry () const |
QSize | frameSize () const |
const QRect & | geometry () 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) |
QGraphicsEffect * | graphicsEffect () const |
QGraphicsProxyWidget * | graphicsProxyWidget () 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 |
QLayout * | layout () 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) |
QPaintEngine * | paintEngine () const override |
const QPalette & | palette () 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 ®ion) |
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 ®ion) |
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 |
QStyle * | style () 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 ®ion) |
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 |
QWindow * | windowHandle () 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< QString > | dynamicPropertyNames () const |
virtual bool | event (QEvent *event) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
template<typename T > | |
T | findChild (const QString &childName=QString ()) const |
template<class T > | |
QList< T > | findChildren (const QRegularExpression ®Exp, 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 QMetaObject * | metaObject () const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const |
QObject * | parent () const |
template<class T = QVariant> | |
T | 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) |
QThread * | thread () 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 | contextMenuEvent (QContextMenuEvent *event) override |
bool | event (QEvent *event) override |
Protected Methods inherited from QWidget | |
virtual void | actionEvent (QActionEvent *event) |
virtual void | changeEvent (QEvent *event) |
virtual void | closeEvent (QCloseEvent *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 | paintEvent (QPaintEvent *event) |
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 () | |
Additional Inherited Members | |
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 QMetaObject & | staticMetaObject () |
static QString | tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >()) |
Protected Slots inherited from QWidget | |
void | updateMicroFocus () |
Related Functions inherited from QWidget | |
QWidgetList | |
WId | |
Related Functions inherited from QObject | |
T | qobject_cast (QObject *object) |
QObjectList | |
The QMainWindow class provides the main GUI application window, commonly referred to as simply the "main window". This class manages it own internal layout structure which supports adding objects like a QMenuBar, QToolBar, QStatusBar, or a QDockWidget. The layout has a center area which can be occupied by any kind of widget.
A main window must contain a central widget.
The central widget can be any class which inherits from QWidget. Common choices include QWidget itset, QTextEdit, or a QGraphicsView. Custom widgets can also be used. A central widget is added to a main window by calling setCentralWidget().
Menus can be displayed on a main window. The horizontal area at the top is called the menu bar and is created by the QMenuBar class. The sub-menu items are created by they QMenu class. The QMainWindow class has a default QMenuBar object which can be retrieved by calling QMainWindow::menuBar().
To create a new entry on the menu bar call menuBar()->addMenu() and pass the name of the menu item. This method returns a pointer which can then be used to add a QAction to the menu. The action is a pointer to an object which can set the icon, tool tip, and declare signal/slot connection indicating what should happen then the menu item is selected.
The following is an example which shows how to create the actions, a menu bar, and menu items.
As an alternative, the QMainWindow default menu bar can be redefined by using the method setMenuBar().
A toolbar can be added to a main window by calling the method QMainWindow::addToolBar(). This method returns a pointer to a new QToolBar object. Normally the same action created for the menu is used for toolbar items. The following is an example showing how to create a new toolbar.
The toolbar display can be adjusted by using the methods QMainWindow::addToolBarBreak(), QMainWindow::insertToolBarBreak(), QToolBar::setAllowedAreas(), and QToolBar::setMovable().
A dock widget is a window which can be docked on the edge of the main window or floating on the user's desktop. They are added to a main window by calling QMainWindow::addDockWidget(). Dock widgets are created by the QDockWidget class.
There are four dock widget areas defined by the Qt::DockWidgetArea enum: left, right, top, and bottom. By default each dock widget area can only contain one vertical or horizontal row of dock widgets. Multiple dock widgets can be stacked on top of each other. A QTabBar is automatically added to show one of the dock widgets at a time.
The following is an example showing how to add dock widgets to a main window.
You can set a status bar by calling setStatusBar(). If you do not set this then one will automatically be created the first time statusBar() is called.
QMainWindow can store the state of its layout with saveState(). It can later be retrieved with restoreState(). The state contains the position and size of toolbars and dock widgets, relative to the size of the main window.
Typedef for QFlags<DockOption> which contains an OR combination of DockOption values.
Refer to QMainWindow::DockOption for the enum documentation.
This enum contains flags that specify the docking behavior of QMainWindow.
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.
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 can not 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. Refer to setTabPosition(). |
|
explicit |
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.
Creates a QToolBar object, setting its window title to title, and inserts it into the top toolbar area.
void QMainWindow::addToolBar | ( | Qt::ToolBarArea | area, |
QToolBar * | toolbar | ||
) |
Adds the toolbar in the specified area on this main window. The new toolbar is placed after any existing toolbar. If this toolbar has already been added to the current QMainWindow, the given toolbar will be moved to the specified area.
void QMainWindow::addToolBar | ( | QToolBar * | toolbar | ) |
Equivalent to calling addToolBar(Qt::TopToolBarArea, toolbar)
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 method returns a nullptr if the central widget has not been set.
|
overrideprotectedvirtual |
Reimplemented from QWidget::contextMenuEvent()
Qt::DockWidgetArea QMainWindow::corner | ( | Qt::Corner | corner | ) | const |
Returns the dock widget area that occupies the specified corner.
|
virtual |
This method is called when the main window receives a context menu event. The default implementation generates a pop up menu with the checkable actions from the dock widgets and toolbars. If there are no toolbars and dock widgets present, this method returns a null pointer.
If you want to create a custom popup menu reimplement this method and return a newly created popup menu. Ownership of the popup menu is transferred to the caller.
DockOptions QMainWindow::dockOptions | ( | ) | const |
Returns the value of the property.
Qt::DockWidgetArea QMainWindow::dockWidgetArea | ( | QDockWidget * | dockwidget | ) | const |
Returns the Qt::DockWidgetArea for dockwidget. If dockwidget has not been added to the main window, this method returns Qt::NoDockWidgetArea.
bool QMainWindow::documentMode | ( | ) | const |
Returns the value of the property.
|
overrideprotected |
Reimplemented from QWidget::event()
QSize QMainWindow::iconSize | ( | ) | const |
Returns the value of the property.
|
signal |
This signal is emitted when the size of the icons used in the window is changed. The new icon size is passed in iconSize. This signal can be connected to other components to help maintain a consistent appearance for your application.
Inserts the newToolbar at the given location in the existing toolbar.
void QMainWindow::insertToolBarBreak | ( | QToolBar * | location | ) |
Inserts a toolbar break before the toolbar specified by the given location.
bool QMainWindow::isAnimated | ( | ) | const |
Returns the value of the property.
bool QMainWindow::isDockNestingEnabled | ( | ) | const |
Returns the value of the property.
QMenuBar * QMainWindow::menuBar | ( | ) | const |
Returns the menu bar for the main window. This method creates an empty menu bar if the menu bar does not exist and then returns a pointer to the new menu bar.
If you want every window in a Mac OS X application to share one menu bar, do not use this method. The menu bar it creates will have this QMainWindow as its parent. Instead, create a menu bar without a parent which can be shared among all the windows.
QWidget * QMainWindow::menuWidget | ( | ) | const |
Returns the menu bar for the main window. This method returns a nullptr if a menu bar has not been constructed.
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 * | location | ) |
Removes a toolbar break previously inserted before the toolbar specified by location.
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.
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 respect the constraints.
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.
bool QMainWindow::restoreState | ( | const QByteArray & | state, |
int | version = 0 |
||
) |
Restores the state of this mainwindow's toolbars and dockwidgets. The version number is compared with that stored in state. If they do not match the mainwindow's state is left unchanged and this method returns false. Otherwise the state is restored and this method returns true.
The following is an example showing how to restore geometry saved using QSettings.
QByteArray QMainWindow::saveState | ( | int | version = 0 | ) | const |
Saves the current state of this mainwindow's toolbars and dockwidgets. 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 as shown below.
|
slot |
Sets the value of the property to enabled.
void QMainWindow::setCentralWidget | ( | QWidget * | widget | ) |
Sets the given widget to be the main window's central widget. QMainWindow takes ownership of the widget pointer and deletes it at the appropriate time.
void QMainWindow::setCorner | ( | Qt::Corner | corner, |
Qt::DockWidgetArea | area | ||
) |
Sets the given dock widget area to occupy the specified corner.
|
slot |
Sets the value of the property to enabled.
void QMainWindow::setDockOptions | ( | DockOptions | options | ) |
Sets the value of the property to options.
void QMainWindow::setDocumentMode | ( | bool | enabled | ) |
Sets the value of the property to enabled.
void QMainWindow::setIconSize | ( | const QSize & | iconSize | ) |
Sets the value of the property to iconSize.
void QMainWindow::setMenuBar | ( | QMenuBar * | 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.
void QMainWindow::setStatusBar | ( | QStatusBar * | statusbar | ) |
Sets the status bar for the main window to statusbar. Setting the status bar to nullptr will remove it from the main window. QMainWindow takes ownership of the statusbar pointer and deletes it at the appropriate time.
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.
void QMainWindow::setTabShape | ( | QTabWidget::TabShape | tabShape | ) |
Sets the value of the property to tabShape.
void QMainWindow::setToolButtonStyle | ( | Qt::ToolButtonStyle | toolButtonStyle | ) |
Sets the value of the property to toolButtonStyle.
|
slot |
Sets the value of the property to set.
void QMainWindow::splitDockWidget | ( | QDockWidget * | first, |
QDockWidget * | second, | ||
Qt::Orientation | orientation | ||
) |
Splits the space covered by the dock widget into two parts. It moves the first dock widget into the first part and moves the second dock widget into the second part. If first is currently in a tab then second will be added as a new tab since a single tab can only contain one dock widget.
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. 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.
QStatusBar * QMainWindow::statusBar | ( | ) | const |
Returns the status bar for the main window. This method creates and returns an empty status bar if the status bar does not exist.
QList< QDockWidget * > QMainWindow::tabifiedDockWidgets | ( | QDockWidget * | dockwidget | ) | const |
Returns the dock widgets that are tabified together with dockwidget.
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.
QTabWidget::TabPosition QMainWindow::tabPosition | ( | Qt::DockWidgetArea | area | ) | const |
Returns the tab position for area.
QTabWidget::TabShape QMainWindow::tabShape | ( | ) | const |
Returns the value of the property.
QWidget * QMainWindow::takeCentralWidget | ( | ) |
Removes the central widget from this main window. The ownership of the removed widget is passed to the caller.
Qt::ToolBarArea QMainWindow::toolBarArea | ( | QToolBar * | toolbar | ) | const |
Returns the Qt::ToolBarArea for toolbar. If toolbar has not been added to the main window, this method returns Qt::NoToolBarArea.
bool QMainWindow::toolBarBreak | ( | QToolBar * | toolbar | ) | const |
Returns whether there is a toolbar break before the toolbar.
Qt::ToolButtonStyle QMainWindow::toolButtonStyle | ( | ) | const |
Returns the value of the property.
|
signal |
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.
bool QMainWindow::unifiedTitleAndToolBarOnMac | ( | ) | const |
Returns the value of the property.
|
This property holds whether manipulating dock widgets and toolbars is animated.
When a dock widget or toolbar is dragged over the main window, the main window adjusts its contents to indicate where the dock widget or toolbar 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().
Properties | Class Methods |
---|---|
read | isAnimated |
write | setAnimated |
|
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().
Properties | Class Methods |
---|---|
read | isDockNestingEnabled |
write | setDockNestingEnabled |
|
This property holds the docking behavior of QMainWindow. The default value is AnimatedDocks | AllowTabbedDocks.
Properties | Class Methods |
---|---|
read | dockOptions |
write | setDockOptions |
|
This property holds whether the tab bar for tabbed dockwidgets is set to document mode. The default is false.
Properties | Class Methods |
---|---|
read | documentMode |
write | setDocumentMode |
|
This property holds the size of toolbar icons displayed on this QMainWindow. The default size is the toolbar icon size from the current GUI style. The size of the supplied icons should not be smaller than the value of this property.
Properties | Class Methods |
---|---|
read | iconSize |
write | setIconSize |
|
This property holds the tab shape used for tabbed dock widgets. The default is QTabWidget::Rounded.
Properties | Class Methods |
---|---|
read | tabShape |
write | setTabShape |
|
This property holds style of toolbar buttons in this mainwindow. The default is Qt::ToolButtonIconOnly.
Properties | Class Methods |
---|---|
read | toolButtonStyle |
write | setToolButtonStyle |
|
This property holds whether the window uses the unified title and toolbar look on Mac OS X. This property is false by default and only has any effect on Mac OS X 10.4 or higher.
If set to true, then the top toolbar area is replaced with a Carbon HIToolbar or a Cocoa NSToolbar (depending on whether CopperSpice was built with Carbon or Cocoa). All toolbars in the top toolbar area and any toolbars added afterwards are moved to that. This means a couple of things.
Setting this back to false will remove these restrictions.
The Qt::WA_MacBrushedMetal attribute takes precedence over this property.
Properties | Class Methods |
---|---|
read | unifiedTitleAndToolBarOnMac |
write | setUnifiedTitleAndToolBarOnMac |