Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QDockWidget Class

TheQDockWidget class provides a widget that can be docked inside aQMainWindow or floated as a top-level window on the desktop.More...

Header:#include <QDockWidget>
Inherits:QWidget

Public Types

enumDockWidgetFeature { DockWidgetClosable, DockWidgetMovable, DockWidgetFloatable, DockWidgetVerticalTitleBar, AllDockWidgetFeatures, NoDockWidgetFeatures }
flagsDockWidgetFeatures

Properties

Public Functions

QDockWidget(const QString & title, QWidget * parent = 0, Qt::WindowFlags flags = 0)
QDockWidget(QWidget * parent = 0, Qt::WindowFlags flags = 0)
~QDockWidget()
Qt::DockWidgetAreasallowedAreas() const
DockWidgetFeaturesfeatures() const
boolisAreaAllowed(Qt::DockWidgetArea area) const
boolisFloating() const
voidsetAllowedAreas(Qt::DockWidgetAreas areas)
voidsetFeatures(DockWidgetFeatures features)
voidsetFloating(bool floating)
voidsetTitleBarWidget(QWidget * widget)
voidsetWidget(QWidget * widget)
QWidget *titleBarWidget() const
QAction *toggleViewAction() const
QWidget *widget() const

Signals

voidallowedAreasChanged(Qt::DockWidgetAreas allowedAreas)
voiddockLocationChanged(Qt::DockWidgetArea area)
voidfeaturesChanged(QDockWidget::DockWidgetFeatures features)
voidtopLevelChanged(bool topLevel)
voidvisibilityChanged(bool visible)

Protected Functions

voidinitStyleOption(QStyleOptionDockWidget * option) const

Reimplemented Protected Functions

virtual voidchangeEvent(QEvent * event)
virtual voidcloseEvent(QCloseEvent * event)
virtual boolevent(QEvent * event)
virtual voidpaintEvent(QPaintEvent * event)
  • 37 protected functions inherited fromQWidget
  • 8 protected functions inherited fromQObject
  • 1 protected function inherited fromQPaintDevice

Additional Inherited Members

  • 19 public slots inherited fromQWidget
  • 1 public slot inherited fromQObject
  • 4 static public members inherited fromQWidget
  • 7 static public members inherited fromQObject
  • 1 protected slot inherited fromQWidget

Detailed Description

TheQDockWidget class provides a widget that can be docked inside aQMainWindow or floated as a top-level window on the desktop.

QDockWidget provides the concept of dock widgets, also know as tool palettes or utility windows. Dock windows are secondary windows placed in thedock widget area around thecentral widget in aQMainWindow.

Dock windows can be moved inside their current area, moved into new areas and floated (e.g., undocked) by the end-user. TheQDockWidget API allows the programmer to restrict the dock widgets ability to move, float and close, as well as the areas in which they can be placed.

Appearance

AQDockWidget consists of a title bar and the content area. The title bar displays the dock widgetswindow title, afloat button and aclose button. Depending on the state of theQDockWidget, thefloat andclose buttons may be either disabled or not shown at all.

The visual appearance of the title bar and buttons is dependent on thestyle in use.

AQDockWidget acts as a wrapper for its child widget, set withsetWidget(). Custom size hints, minimum and maximum sizes and size policies should be implemented in the child widget.QDockWidget will respect them, adjusting its own constraints to include the frame and title. Size constraints should not be set on theQDockWidget itself, because they change depending on whether it is docked; a dockedQDockWidget has no frame and a smaller title bar.

See alsoQMainWindow andDock Widgets Example.

Member Type Documentation

enum QDockWidget::DockWidgetFeature
flags QDockWidget::DockWidgetFeatures

ConstantValueDescription
QDockWidget::DockWidgetClosable0x01The dock widget can be closed. On some systems the dock widget always has a close button when it's floating (for example on MacOS 10.5).
QDockWidget::DockWidgetMovable0x02The dock widget can be moved between docks by the user.
QDockWidget::DockWidgetFloatable0x04The dock widget can be detached from the main window, and floated as an independent window.
QDockWidget::DockWidgetVerticalTitleBar0x08The dock widget displays a vertical title bar on its left side. This can be used to increase the amount of vertical space in aQMainWindow.
QDockWidget::AllDockWidgetFeaturesDockWidgetClosable | DockWidgetMovable | DockWidgetFloatable(Deprecated) The dock widget can be closed, moved, and floated. Since new features might be added in future releases, the look and behavior of dock widgets might change if you use this flag. Please specify individual flags instead.
QDockWidget::NoDockWidgetFeatures0x00The dock widget cannot be closed, moved, or floated.

The DockWidgetFeatures type is a typedef forQFlags<DockWidgetFeature>. It stores an OR combination of DockWidgetFeature values.

Property Documentation

allowedAreas :Qt::DockWidgetAreas

This property holds areas where the dock widget may be placed.

The default isQt::AllDockWidgetAreas.

Access functions:

Qt::DockWidgetAreasallowedAreas() const
voidsetAllowedAreas(Qt::DockWidgetAreas areas)

Notifier signal:

voidallowedAreasChanged(Qt::DockWidgetAreas allowedAreas)

See alsoQt::DockWidgetArea.

features :DockWidgetFeatures

This property holds whether the dock widget is movable, closable, and floatable.

By default, this property is set to a combination ofDockWidgetClosable,DockWidgetMovable andDockWidgetFloatable.

Access functions:

DockWidgetFeaturesfeatures() const
voidsetFeatures(DockWidgetFeatures features)

Notifier signal:

voidfeaturesChanged(QDockWidget::DockWidgetFeatures features)

See alsoDockWidgetFeature.

floating :bool

This property holds whether the dock widget is floating.

A floating dock widget is presented to the user as an independent window "on top" of its parentQMainWindow, instead of being docked in theQMainWindow.

By default, this property is true.

Access functions:

boolisFloating() const
voidsetFloating(bool floating)

See alsoisWindow().

windowTitle :QString

This property holds the dock widget title (caption).

By default, this property contains an empty string.

Access functions:

QStringwindowTitle() const
voidsetWindowTitle(const QString &)

Member Function Documentation

QDockWidget::QDockWidget(constQString & title,QWidget * parent = 0,Qt::WindowFlags flags = 0)

Constructs aQDockWidget with parentparent and window flagsflags. The dock widget will be placed in the left dock widget area.

The window title is set totitle. This title is used when theQDockWidget is docked and undocked. It is also used in the context menu provided byQMainWindow.

See alsosetWindowTitle().

QDockWidget::QDockWidget(QWidget * parent = 0,Qt::WindowFlags flags = 0)

Constructs aQDockWidget with parentparent and window flagsflags. The dock widget will be placed in the left dock widget area.

QDockWidget::~QDockWidget()

Destroys the dock widget.

[virtual protected]void QDockWidget::changeEvent(QEvent * event)

Reimplemented fromQWidget::changeEvent().

[virtual protected]void QDockWidget::closeEvent(QCloseEvent * event)

Reimplemented fromQWidget::closeEvent().

[signal]void QDockWidget::dockLocationChanged(Qt::DockWidgetArea area)

This signal is emitted when the dock widget is moved to another dockarea, or is moved to a different location in its current dock area. This happens when the dock widget is moved programmatically or is dragged to a new location by the user.

This function was introduced in Qt 4.3.

[virtual protected]bool QDockWidget::event(QEvent * event)

Reimplemented fromQObject::event().

[protected]void QDockWidget::initStyleOption(QStyleOptionDockWidget * option) const

Initializeoption with the values from thisQDockWidget. This method is useful for subclasses when they need aQStyleOptionDockWidget, but don't want to fill in all the information themselves.

See alsoQStyleOption::initFrom().

bool QDockWidget::isAreaAllowed(Qt::DockWidgetArea area) const

Returns true if this dock widget can be placed in the givenarea; otherwise returns false.

[virtual protected]void QDockWidget::paintEvent(QPaintEvent * event)

Reimplemented fromQWidget::paintEvent().

void QDockWidget::setTitleBarWidget(QWidget * widget)

Sets an arbitrarywidget as the dock widget's title bar. Ifwidget is 0, any custom title bar widget previously set on the dock widget is removed, but not deleted, and the default title bar will be used instead.

If a title bar widget is set,QDockWidget will not use native window decorations when it is floated.

Here are some tips for implementing custom title bars:

  • Mouse events that are not explicitly handled by the title bar widget must be ignored by callingQMouseEvent::ignore(). These events then propagate to theQDockWidget parent, which handles them in the usual manner, moving when the title bar is dragged, docking and undocking when it is double-clicked, etc.
  • WhenDockWidgetVerticalTitleBar is set onQDockWidget, the title bar widget is repositioned accordingly. InresizeEvent(), the title bar should check what orientation it should assume:
    QDockWidget*dockWidget= qobject_cast<QDockWidget*>(parentWidget());if (dockWidget->features()&QDockWidget::DockWidgetVerticalTitleBar) {// I need to be vertical}else {// I need to be horizontal}
  • The title bar widget must have a validQWidget::sizeHint() andQWidget::minimumSizeHint(). These functions should take into account the current orientation of the title bar.
  • It is not possible to remove a title bar from a dock widget. However, a similar effect can be achieved by setting a default constructedQWidget as the title bar widget.

Usingqobject_cast() as shown above, the title bar widget has full access to its parentQDockWidget. Hence it can perform such operations as docking and hiding in response to user actions.

This function was introduced in Qt 4.3.

See alsotitleBarWidget() andDockWidgetVerticalTitleBar.

void QDockWidget::setWidget(QWidget * widget)

Sets the widget for the dock widget towidget.

If the dock widget is visible whenwidget is added, you mustshow() it explicitly.

Note that you must add the layout of thewidget before you call this function; if not, thewidget will not be visible.

See alsowidget().

QWidget * QDockWidget::titleBarWidget() const

Returns the custom title bar widget set on theQDockWidget, or 0 if no custom title bar has been set.

This function was introduced in Qt 4.3.

See alsosetTitleBarWidget().

QAction * QDockWidget::toggleViewAction() const

Returns a checkable action that can be used to show or close this dock widget.

The action's text is set to the dock widget's window title.

See alsoQAction::text andQWidget::windowTitle.

[signal]void QDockWidget::topLevelChanged(bool topLevel)

This signal is emitted when thefloating property changes. ThetopLevel parameter is true if the dock widget is now floating; otherwise it is false.

See alsoisWindow().

[signal]void QDockWidget::visibilityChanged(bool visible)

This signal is emitted when the dock widget becomesvisible (or invisible). This happens when the widget is hidden or shown, as well as when it is docked in a tabbed dock area and its tab becomes selected or unselected.

This function was introduced in Qt 4.3.

QWidget * QDockWidget::widget() const

Returns the widget for the dock widget. This function returns zero if the widget has not been set.

See alsosetWidget().

© 2016 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 theGNU 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.


[8]ページ先頭

©2009-2025 Movatter.jp