Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Fonctions  · 

QDockWindow Class Reference

The QDockWindow class provides a widget which can be docked inside a QDockArea or floated as a top level window on the desktop. More...

#include <qdockwindow.h>

Inherits QFrame.

Inherited by QToolBar.

List of all member functions.

Public Members

Public Slots

Signals

Properties

  • int closeMode - the close mode of a dock window
  • bool horizontallyStretchable - whether the dock window is horizontally stretchable
  • bool movingEnabled - whether the user can move the dock window within the dock area, move the dock window to another dock area, or float the dock window
  • bool newLine - whether the dock window prefers to start a new line in the dock area
  • int offset - the dock window's preferred offset from the dock area's left edge (top edge for vertical dock areas)
  • bool opaqueMoving - whether the dock window will be shown normally whilst it is being moved
  • Place place  (read only)
  • bool resizeEnabled - whether the dock window is resizeable
  • bool stretchable - whether the dock window is stretchable in the current orientation()  (read only)
  • bool verticallyStretchable - whether the dock window is vertically stretchable

Detailed Description

The QDockWindow class provides a widget which can be docked inside a QDockArea or floated as a top level window on the desktop.

This class handles moving, resizing, docking and undocking dock windows. QToolBar is a subclass of QDockWindow so the functionality provided for dock windows is available with the same API for toolbars.

QDockWindows in a QDockArea

Two QDockWindows (QToolBars) in a QDockArea

A QDockWindow

A Floating QDockWindow

If the user drags the dock window into the dock area the dock window will be docked. If the user drags the dock area outside any dock areas the dock window will be undocked (floated) and will become a top level window. Double clicking a floating dock window's titlebar will dock the dock window to the last dock area it was docked in. Double clicking a docked dock window's handle will undock (float) the dock window. If the user clicks the close button (which appears on floating dock windows by default) the dock window will disappear. You can control whether or not a dock window has a close button with setCloseMode().

QMainWindow provides four dock areas (top, left, right and bottom) which can be used by dock windows. For many applications using the dock areas provided by QMainWindow is sufficient. (See the QDockArea documentation if you want to create your own dock areas.) In QMainWindow a right-click popup menu (the dock window menu) is available which lists dock windows and can be used to show or hide them.

When you construct a dock window you must pass it a QDockArea or a QMainWindow as its parent if you want it docked. Pass 0 for the parent if you want it floated.

    QToolBar *fileTools = new QToolBar( this, "File Actions" );
    moveDockWindow( fileTools, Left );
    

In the example above we create a new QToolBar in the constructor of a QMainWindow subclass (so that the this pointer points to the QMainWindow). By default the toolbar will be added to the Top dock area, but we've moved it to the Left dock area.

A dock window is often used to contain a single widget. In these cases the widget can be set by calling setWidget(). If you're constructing a dock window that contains multiple widgets, e.g. a toolbar, arrange the widgets within a box layout inside the dock window. To do this use the boxLayout() function to get a pointer to the dock window's box layout, then add widgets to the layout using the box layout's QBoxLayout::addWidget() function. The dock window will dynamically set the orientation of the layout to be vertical or horizontal as necessary, although you can control this yourself with setOrientation().

Although a common use of dock windows is for toolbars, they can be used with any widgets. (See the Qt Designer and Qt Linguist applications, for example.) When using larger widgets it may make sense for the dock window to be resizable by calling setResizeEnabled(). Resizable dock windows are given splitter-like handles to allow the user to resize them within their dock area. When resizable dock windows are undocked they become top level windows and can be resized like any other top level windows, e.g. by dragging a corner or edge.

Dock windows can be docked and undocked using dock() and undock(). A dock window's orientation can be set with setOrientation(). You can also use QDockArea::moveDockWindow(). If you're using a QMainWindow, QMainWindow::moveDockWindow() and QMainWindow::removeDockWindow() are available.

A dock window can have some preferred settings, for example, you can set a preferred offset from the left edge (or top edge for vertical dock areas) of the dock area using setOffset(). If you'd prefer a dock window to start on a new line when it is docked use setNewLine(). The setFixedExtentWidth() and setFixedExtentHeight() functions can be used to define the dock window's preferred size, and the setHorizontallyStretchable() and setVerticallyStretchable() functions set whether the dock window can be stretched or not. Dock windows can be moved by default, but this can be changed with setMovingEnabled(). When a dock window is moved it is shown as a rectangular outline, but it can be shown normally using setOpaqueMoving().

When a dock window's visibility changes, i.e. it is shown or hidden, the visibilityChanged() signal is emitted. When a dock window is docked, undocked or moved inside the dock area the placeChanged() signal is emitted.

See also Main Window and Related Classes.


Member Type Documentation

QDockWindow::CloseMode

This enum type specifies when (if ever) a dock window has a close button.

  • QDockWindow::Never - The dock window never has a close button and cannot be closed by the user.
  • QDockWindow::Docked - The dock window has a close button only when docked.
  • QDockWindow::Undocked - The dock window has a close button only when floating.
  • QDockWindow::Always - The dock window always has a close button.

QDockWindow::Place

This enum specifies the possible locations for a QDockWindow:

  • QDockWindow::InDock - Inside a QDockArea.
  • QDockWindow::OutsideDock - Floating as a top level window on the desktop.

Member Function Documentation

QDockWindow::QDockWindow ( Place p = InDock, QWidget * parent = 0, const char * name = 0, WFlags f = 0 )

Constructs a QDockWindow with parent parent, called name and with widget flags f.

If p is InDock, the dock window is docked into a dock area and parent must be a QDockArea or a QMainWindow. If the parent is a QMainWindow the dock window will be docked in the main window's Top dock area.

If p is OutsideDock, the parent must be 0 and the dock window is created as a floating window.

We recommend creating the dock area InDock with a QMainWindow as parent then calling QMainWindow::moveDockWindow() to move the dock window where you want it.

QDockWindow::QDockWindow ( QWidget * parent, const char * name = 0, WFlags f = 0 )

Constructs a QDockWindow with parent parent, called name and with widget flags f.

QDockArea * QDockWindow::area () const

Returns the dock area in which this dock window is docked, or 0 if the dock window is floating.

QBoxLayout * QDockWindow::boxLayout ()

Returns the layout which is used for adding widgets to the dock window. The layout's orientation is set automatically to match the orientation of the dock window. You can add widgets to the layout using the box layout's QBoxLayout::addWidget() function.

If the dock window only needs to contain a single widget use setWidget() instead.

See also setWidget() and setOrientation().

int QDockWindow::closeMode () const

Returns the close mode of a dock window. See the "closeMode" property for details.

void QDockWindow::dock () [virtual slot]

Docks the dock window into the last dock area in which it was docked.

If the dock window has no last dock area (e.g. it was created as a floating window and has never been docked), or if the last dock area it was docked in does not exist (e.g. the dock area has been deleted), nothing happens.

The dock window will dock with the dock area regardless of the return value of QDockArea::isDockWindowAccepted().

See also undock(), QDockArea::moveDockWindow(), QDockArea::removeDockWindow(), QMainWindow::moveDockWindow(), QMainWindow::removeDockWindow(), and QDockArea::isDockWindowAccepted().

QSize QDockWindow::fixedExtent () const

Returns the dock window's preferred size (fixed extent).

See also setFixedExtentWidth() and setFixedExtentHeight().

bool QDockWindow::isCloseEnabled () const

Returns TRUE if the dock window has a close button; otherwise returns FALSE. The result depends on the dock window's Place and its CloseMode.

See also closeMode.

bool QDockWindow::isHorizontalStretchable () const

This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

bool QDockWindow::isHorizontallyStretchable () const

Returns TRUE if the dock window is horizontally stretchable; otherwise returns FALSE. See the "horizontallyStretchable" property for details.

bool QDockWindow::isMovingEnabled () const

Returns TRUE if the user can move the dock window within the dock area, move the dock window to another dock area, or float the dock window; otherwise returns FALSE. See the "movingEnabled" property for details.

bool QDockWindow::isResizeEnabled () const

Returns TRUE if the dock window is resizeable; otherwise returns FALSE. See the "resizeEnabled" property for details.

bool QDockWindow::isStretchable () const

Returns TRUE if the dock window is stretchable in the current orientation(); otherwise returns FALSE. See the "stretchable" property for details.

bool QDockWindow::isVerticalStretchable () const

This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

bool QDockWindow::isVerticallyStretchable () const

Returns TRUE if the dock window is vertically stretchable; otherwise returns FALSE. See the "verticallyStretchable" property for details.

bool QDockWindow::newLine () const

Returns TRUE if the dock window prefers to start a new line in the dock area; otherwise returns FALSE. See the "newLine" property for details.

int QDockWindow::offset () const

Returns the dock window's preferred offset from the dock area's left edge (top edge for vertical dock areas). See the "offset" property for details.

bool QDockWindow::opaqueMoving () const

Returns TRUE if the dock window will be shown normally whilst it is being moved; otherwise returns FALSE. See the "opaqueMoving" property for details.

Qt::Orientation QDockWindow::orientation () const

Returns the orientation of the dock window.

See also orientationChanged().

void QDockWindow::orientationChanged ( Orientation o ) [signal]

This signal is emitted when the orientation of the dock window is changed. The new orientation is o.

Place QDockWindow::place () const

This function returns where the dock window is placed. This is either InDock or OutsideDock.

See also QDockArea::moveDockWindow(), QDockArea::removeDockWindow(), QMainWindow::moveDockWindow(), and QMainWindow::removeDockWindow().

void QDockWindow::placeChanged ( QDockWindow::Place p ) [signal]

This signal is emitted when the dock window is docked (p is InDock), undocked (p is OutsideDock) or moved inside the the dock area.

See also QDockArea::moveDockWindow(), QDockArea::removeDockWindow(), QMainWindow::moveDockWindow(), and QMainWindow::removeDockWindow().

void QDockWindow::setCloseMode ( int m ) [virtual]

Sets the close mode of a dock window to m. See the "closeMode" property for details.

void QDockWindow::setFixedExtentHeight ( int h ) [virtual]

Sets the dock window's preferred height for its fixed extent (size) to h.

See also setFixedExtentWidth().

void QDockWindow::setFixedExtentWidth ( int w ) [virtual]

Sets the dock window's preferred width for its fixed extent (size) to w.

See also setFixedExtentHeight().

void QDockWindow::setHorizontalStretchable ( bool b )

This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

void QDockWindow::setHorizontallyStretchable ( bool b ) [virtual]

Sets whether the dock window is horizontally stretchable to b. See the "horizontallyStretchable" property for details.

void QDockWindow::setMovingEnabled ( bool b ) [virtual]

Sets whether the user can move the dock window within the dock area, move the dock window to another dock area, or float the dock window to b. See the "movingEnabled" property for details.

void QDockWindow::setNewLine ( bool b ) [virtual]

Sets whether the dock window prefers to start a new line in the dock area to b. See the "newLine" property for details.

void QDockWindow::setOffset ( int o ) [virtual]

Sets the dock window's preferred offset from the dock area's left edge (top edge for vertical dock areas) to o. See the "offset" property for details.

void QDockWindow::setOpaqueMoving ( bool b ) [virtual]

Sets whether the dock window will be shown normally whilst it is being moved to b. See the "opaqueMoving" property for details.

void QDockWindow::setOrientation ( Orientation o ) [virtual slot]

Sets the orientation of the dock window to o. The orientation is propagated to the layout boxLayout().

Warning: All undocked QToolBars will always have a horizontal orientation.

void QDockWindow::setResizeEnabled ( bool b ) [virtual]

Sets whether the dock window is resizeable to b. See the "resizeEnabled" property for details.

void QDockWindow::setVerticalStretchable ( bool b )

This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

void QDockWindow::setVerticallyStretchable ( bool b ) [virtual]

Sets whether the dock window is vertically stretchable to b. See the "verticallyStretchable" property for details.

void QDockWindow::setWidget ( QWidget * w ) [virtual]

Sets the dock window's main widget to w.

See also boxLayout().

void QDockWindow::undock () [virtual slot]

Undocks the QDockWindow from its current dock area if it is docked; otherwise does nothing.

See also dock(), QDockArea::moveDockWindow(), QDockArea::removeDockWindow(), QMainWindow::moveDockWindow(), and QMainWindow::removeDockWindow().

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

This signal is emitted when the visibility of the dock window relatively to its dock area is changed. If visible is TRUE, the QDockWindow is now visible to the dock area, otherwise it has been hidden.

A dock window can be hidden if it has a close button which the user has clicked. In the case of a QMainWindow a dock window can have its visibility changed (hidden or shown) by clicking its name in the dock window menu that lists the QMainWindow's dock windows.

QWidget * QDockWindow::widget () const

Returns the dock window's main widget.

See also setWidget().


Property Documentation

int closeMode

This property holds the close mode of a dock window.

Defines when (if ever) the dock window has a close button. The choices are Never, Docked (i.e. only when docked), Undocked (only when undocked, i.e. floated) or Always.

The default is Never.

Set this property's value with setCloseMode() and get this property's value with closeMode().

bool horizontallyStretchable

This property holds whether the dock window is horizontally stretchable.

A dock window is horizontally stretchable if you call setHorizontallyStretchable(TRUE) or setResizeEnabled(TRUE).

See also resizeEnabled.

Set this property's value with setHorizontallyStretchable() and get this property's value with isHorizontallyStretchable().

bool movingEnabled

This property holds whether the user can move the dock window within the dock area, move the dock window to another dock area, or float the dock window.

This property is TRUE by default.

Set this property's value with setMovingEnabled() and get this property's value with isMovingEnabled().

bool newLine

This property holds whether the dock window prefers to start a new line in the dock area.

The default is FALSE, i.e. the dock window doesn't require a new line in the dock area.

Set this property's value with setNewLine() and get this property's value with newLine().

int offset

This property holds the dock window's preferred offset from the dock area's left edge (top edge for vertical dock areas).

The default is 0.

Set this property's value with setOffset() and get this property's value with offset().

bool opaqueMoving

This property holds whether the dock window will be shown normally whilst it is being moved.

If this property is FALSE, (the default), the dock window will be represented by an outline rectangle whilst it is being moved.

Warning: Currently opaque moving has some problems and we do not recommend using it at this time. We expect to fix these problems in a future release.

Set this property's value with setOpaqueMoving() and get this property's value with opaqueMoving().

bool resizeEnabled

This property holds whether the dock window is resizeable.

A resizeable dock window can be resized using splitter-like handles inside a dock area and like every other top level window when floating.

A dock window is both horizontally and vertically stretchable if you call setResizeEnabled(TRUE).

This property is FALSE by default.

See also verticallyStretchable and horizontallyStretchable.

Set this property's value with setResizeEnabled() and get this property's value with isResizeEnabled().

bool stretchable

This property holds whether the dock window is stretchable in the current orientation().

This property can be set using setHorizontallyStretchable() and setVerticallyStretchable(), or with setResizeEnabled().

See also resizeEnabled.

Get this property's value with isStretchable().

bool verticallyStretchable

This property holds whether the dock window is vertically stretchable.

A dock window is vertically stretchable if you call setVerticallyStretchable(TRUE) or setResizeEnabled(TRUE).

See also resizeEnabled.

Set this property's value with setVerticallyStretchable() and get this property's value with isVerticallyStretchable().


This file is part of the Qt toolkit. Copyright © 1995-2003 Trolltech. All Rights Reserved.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. «Le projet de loi des droits du développeur» : quelles conditions doivent remplir les entreprises pour que le développeur puisse réussir ? 69
  2. Les développeurs détestent-ils les antivirus ? Un programmeur manifeste sa haine envers ces solutions de sécurité 27
  3. Une nouvelle ère d'IHM 3D pour les automobiles, un concept proposé par Digia et implémenté avec Qt 3
  4. Qt Creator 2.5 est sorti en beta, l'EDI supporte maintenant plus de fonctionnalités de C++11 2
  5. Vingt sociétés montrent leurs décodeurs basés sur Qt au IPTV World Forum, en en exploitant diverses facettes (déclaratif, Web, widgets) 0
  6. PySide devient un add-on Qt et rejoint le Qt Project et le modèle d'open gouvernance 1
  7. Thread travailleur avec Qt en utilisant les signaux et les slots, un article de Christophe Dumez traduit par Thibaut Cuvelier 1
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 101
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 51
  4. «Le projet de loi des droits du développeur» : quelles conditions doivent remplir les entreprises pour que le développeur puisse réussir ? 69
  5. Les développeurs détestent-ils les antivirus ? Un programmeur manifeste sa haine envers ces solutions de sécurité 27
  6. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  7. Qt Commercial : Digia organise un webinar gratuit le 27 mars sur la conception d'interfaces utilisateur et d'applications avec le framework 0
Page suivante

Le Qt Developer Network au hasard

Logo

Introduction à Qt Quick pour les développeurs C++

Le Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 3.2
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web