Qt:Документация 4.3.2/qdockwidget

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск
40px Внимание: Актуальная версия перевода документации находится здесь

__NOTOC__

Image:qt-logo.png

Главная · Все классы · Основные классы · Классы по группам · Модули · Функции

Image:trolltech-logo.png

Содержание

[править] QDockWidget Class Reference
[модуль QtGui ]

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

 #include <QDockWidget>

Inherits QWidget.

[править] Открытые типы

[править] Свойства

  • 56 свойства унаследованных от QWidget
  • 1 свойство унаследованное от QObject

[править] Открытые функции

  • 201 открытых функций унаследованных от QWidget
  • 29 открытых функций унаследованных от QObject
  • 12 открытых функций унаследованных от QPaintDevice

[править] Сигналы

  • 1 сигнал унаследованный от QWidget
  • 1 сигнал унаследованный от QObject

[править] Защищенные функции

  • 38 защищенных функций унаследованных от QWidget
  • 7 защищенных функций унаследованных от QObject
  • 1 защищенная функция унаследованна от QPaintDevice

[править] Дополнительные унаследованные члены

  • 19 открытых слотов унаследованных от QWidget
  • 1 открытый слот унаследованный от QObject
  • 4 статических открытых члена унаследованных от QWidget
  • 5 статических открытых члена унаследованных от QObject
  • 1 защищенный слот унаследованный от QWidget

[править] Подробное описание

The QDockWidget class provides a widget that can be docked inside a QMainWindow 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 the dock widget area around the central widget in a QMainWindow.

center

Dock windows can be moved inside their current area, moved into new areas and floated (e.g. undocked) by the end-user. The QDockWidget 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

A QDockWidget consists of a title bar and the content area. The title bar displays the dock widgets window title, a float button and a close button. Depending on the state of the QDockWidget, the float and close buttons may be either disabled or not shown at all.

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

A QDockWidget acts as a wrapper for its child widget, set with setWidget(). 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 the QDockWidget itself, because they change depending on wether it is docked; a docked QDockWidget has no frame and a smaller title bar.

See also QMainWindow and Dock Widgets Example.


[править] Описание типов членов

[править]
enum QDockWidget::DockWidgetFeature
flags QDockWidget::DockWidgetFeatures

Constant Value Description
QDockWidget::DockWidgetClosable 0x01 The dock widget can be closed.
QDockWidget::DockWidgetMovable 0x02 The dock widget can be moved between docks by the user.
QDockWidget::DockWidgetFloatable 0x04 The dock widget can be detached from the main window, and floated as an independent window.
QDockWidget::DockWidgetVerticalTitleBar 0x08 The dock widget displays a vertical title bar on its left side. This can be used to increase the amount of vertical space in a QMainWindow.
QDockWidget::AllDockWidgetFeatures DockWidgetClosable | 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::NoDockWidgetFeatures 0x00 The dock widget cannot be closed, moved, or floated.

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


[править] Описание свойств

[править]
allowedAreas : Qt::DockWidgetAreas

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

The default is Qt::AllDockWidgetAreas.

Функции доступа:

  • Qt::DockWidgetAreas allowedAreas () const
  • void setAllowedAreas ( Qt::DockWidgetAreas areas )

See also Qt::DockWidgetArea.

[править]
features : DockWidgetFeatures

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

Функции доступа:

  • DockWidgetFeatures features () const
  • void setFeatures ( DockWidgetFeatures features )

See also DockWidgetFeature.

[править]
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 parent QMainWindow, instead of being docked in the QMainWindow.

Функции доступа:

  • bool isFloating () const
  • void setFloating ( bool floating )

See also isWindow().


[править] Описание функций-членов

[править]
QDockWidget::QDockWidget ( const QString & title, QWidget * parent = 0, Qt::WindowFlags flags = 0 )

Constructs a QDockWidget with parent parent and window flags flags. The dock widget will be placed in the left dock widget area.

The window title is set to title. This title is used when the QDockWidget is docked and undocked. It is also used in the context menu provided by QMainWindow.

See also setWindowTitle().

[править]
QDockWidget::QDockWidget ( QWidget * parent = 0, Qt::WindowFlags flags = 0 )

Constructs a QDockWidget with parent parent and window flags flags. The dock widget will be placed in the left dock widget area.

[править]
QDockWidget::~QDockWidget ()

Destroys the dock widget.

[править]
void QDockWidget::allowedAreasChanged ( Qt::DockWidgetAreas allowedAreas ) [signal]

This signal is emitted when the allowedAreas property changes. The allowedAreas parameter gives the new value of the property.

[править]
void QDockWidget::dockLocationChanged ( Qt::DockWidgetArea area ) [signal]

This signal is emitted when the dock widget is moved to another dock area, 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.

[править]
void QDockWidget::featuresChanged ( QDockWidget::DockWidgetFeatures features ) [signal]

This signal is emitted when the features property changes. The features parameter gives the new value of the property.

[править]
void QDockWidget::initStyleOption ( QStyleOptionDockWidget * option ) const [protected]

Initialize option with the values from this QDockWidget. This method is useful for subclasses when they need a QStyleOptionDockWidget, but don't want to fill in all the information themselves.

See also QStyleOption::initFrom().

[править]
bool QDockWidget::isAreaAllowed ( Qt::DockWidgetArea area ) const

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

[править]
void QDockWidget::setTitleBarWidget ( QWidget * widget )

Sets an arbitrary widget as the dock widget's title bar. If widget is 0, the title bar widget is removed, but not deleted.

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 calling QMouseEvent::ignore(). These events then propagate to the QDockWidget parent, which handles them in the usual manner, moving when the title bar is dragged, docking and undocking when it is double-clicked, etc.
  • When DockWidgetVerticalTitleBar is set on QDockWidget, the title bar widget is repositioned accordingly. In resizeEvent(), the title bar should check what orientation it should assume:
     QDockWidget *dockWidget = qobject_cast<QDockWidget*>(parentWidget()); if (dockWidget->features() &amp; QDockWidget::DockWidgetVerticalTitleBar) {     // I need to be vertical } else {     // I need to be horizontal }


Using qobject_cast as shown above, the title bar widget has full access to its parent QDockWidget. Hence it can perform such operations as docking and hiding in response to user actions.


See also titleBarWidget() and DockWidgetVerticalTitleBar.


[править]
void QDockWidget::setWidget ( QWidget * widget )

Sets the widget for the dock widget to widget.


See also widget().


[править]
QWidget * QDockWidget::titleBarWidget () const

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


See also setTitleBarWidget().


[править]
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 also QAction::text and QWidget::windowTitle.


[править]
void QDockWidget::topLevelChanged ( bool topLevel ) [signal]

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


See also isWindow().


[править]
void QDockWidget::visibilityChanged ( bool visible ) [signal]

This signal is emitted when the dock widget becomes visible (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 also setWidget().


Copyright © 2007 Trolltech Trademarks
Qt 4.3.2