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

QMdiArea Class

TheQMdiArea widget provides an area in which MDI windows are displayed.More...

Header:#include <QMdiArea>
Since: Qt 4.3
Inherits:QAbstractScrollArea

Public Types

enumAreaOption { DontMaximizeSubWindowOnActivation }
flagsAreaOptions
enumViewMode { SubWindowView, TabbedView }
enumWindowOrder { CreationOrder, StackingOrder, ActivationHistoryOrder }

Properties

Public Functions

QMdiArea(QWidget * parent = 0)
~QMdiArea()
WindowOrderactivationOrder() const
QMdiSubWindow *activeSubWindow() const
QMdiSubWindow *addSubWindow(QWidget * widget, Qt::WindowFlags windowFlags = 0)
QBrushbackground() const
QMdiSubWindow *currentSubWindow() const
booldocumentMode() const
voidremoveSubWindow(QWidget * widget)
voidsetActivationOrder(WindowOrder order)
voidsetBackground(const QBrush & background)
voidsetDocumentMode(bool enabled)
voidsetOption(AreaOption option, bool on = true)
voidsetTabPosition(QTabWidget::TabPosition position)
voidsetTabShape(QTabWidget::TabShape shape)
voidsetTabsClosable(bool closable)
voidsetTabsMovable(bool movable)
voidsetViewMode(ViewMode mode)
QList<QMdiSubWindow *>subWindowList(WindowOrder order = CreationOrder) const
QTabWidget::TabPositiontabPosition() const
QTabWidget::TabShapetabShape() const
booltabsClosable() const
booltabsMovable() const
booltestOption(AreaOption option) const
ViewModeviewMode() const

Reimplemented Public Functions

virtual QSizeminimumSizeHint() const
virtual QSizesizeHint() const

Public Slots

  • 19 public slots inherited fromQWidget
  • 1 public slot inherited fromQObject

Signals

voidsubWindowActivated(QMdiSubWindow * window)

Reimplemented Protected Functions

virtual voidchildEvent(QChildEvent * childEvent)
virtual boolevent(QEvent * event)
virtual booleventFilter(QObject * object, QEvent * event)
virtual voidpaintEvent(QPaintEvent * paintEvent)
virtual voidresizeEvent(QResizeEvent * resizeEvent)
virtual voidscrollContentsBy(int dx, int dy)
virtual voidshowEvent(QShowEvent * showEvent)
virtual voidtimerEvent(QTimerEvent * timerEvent)
virtual boolviewportEvent(QEvent * event)

Protected Slots

voidsetupViewport(QWidget * viewport)

Additional Inherited Members

Detailed Description

TheQMdiArea widget provides an area in which MDI windows are displayed.

QMdiArea functions, essentially, like a window manager for MDI windows. For instance, it draws the windows it manages on itself and arranges them in a cascading or tile pattern.QMdiArea is commonly used as the center widget in aQMainWindow to create MDI applications, but can also be placed in any layout. The following code adds an area to a main window:

QMainWindow*mainWindow=newQMainWindow;    mainWindow->setCentralWidget(mdiArea);

Unlike the window managers for top-level windows, all window flags (Qt::WindowFlags) are supported byQMdiArea as long as the flags are supported by the current widget style. If a specific flag is not supported by the style (e.g., theWindowShadeButtonHint), you can still shade the window with showShaded().

Subwindows inQMdiArea are instances ofQMdiSubWindow. They are added to an MDI area withaddSubWindow(). It is common to pass aQWidget, which is set as the internal widget, to this function, but it is also possible to pass aQMdiSubWindow directly.The class inheritsQWidget, and you can use the same API as with a normal top-level window when programming.QMdiSubWindow also has behavior that is specific to MDI windows. See theQMdiSubWindow class description for more details.

A subwindow becomes active when it gets the keyboard focus, or whensetFocus() is called. The user activates a window by moving focus in the usual ways. The MDI area emits thesubWindowActivated() signal when the active window changes, and theactiveSubWindow() function returns the active subwindow.

The convenience functionsubWindowList() returns a list of all subwindows. This information could be used in a popup menu containing a list of windows, for example.

The subwindows are sorted by the currentWindowOrder. This is used for thesubWindowList() and foractivateNextSubWindow() and acivatePreviousSubWindow(). Also, it is used when cascading or tiling the windows withcascadeSubWindows() andtileSubWindows().

QMdiArea provides two built-in layout strategies for subwindows:cascadeSubWindows() andtileSubWindows(). Both are slots and are easily connected to menu entries.

Note:The default scroll bar property forQMdiArea isQt::ScrollBarAlwaysOff.

See alsoQMdiSubWindow.

Member Type Documentation

enum QMdiArea::AreaOption
flags QMdiArea::AreaOptions

This enum describes options that customize the behavior of theQMdiArea.

ConstantValueDescription
QMdiArea::DontMaximizeSubWindowOnActivation0x1When the active subwindow is maximized, the default behavior is to maximize the next subwindow that is activated. Set this option if you do not want this behavior.

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

enum QMdiArea::ViewMode

This enum describes the view mode of the area; i.e. how sub-windows will be displayed.

ConstantValueDescription
QMdiArea::SubWindowView0Display sub-windows with window frames (default).
QMdiArea::TabbedView1Display sub-windows with tabs in a tab bar.

This enum was introduced or modified in Qt 4.4.

See alsosetViewMode().

enum QMdiArea::WindowOrder

Specifies the criteria to use for ordering the list of child windows returned bysubWindowList(). The functionscascadeSubWindows() andtileSubWindows() follow this order when arranging the windows.

ConstantValueDescription
QMdiArea::CreationOrder0The windows are returned in the order of their creation.
QMdiArea::StackingOrder1The windows are returned in the order in which they are stacked, with the top-most window being last in the list.
QMdiArea::ActivationHistoryOrder2The windows are returned in the order in which they were activated.

See alsosubWindowList().

Property Documentation

activationOrder :WindowOrder

This property holds the ordering criteria for subwindow lists.

This property specifies the ordering criteria for the list of subwindows returned bysubWindowList(). By default, it is the window creation order.

This property was introduced in Qt 4.4.

Access functions:

WindowOrderactivationOrder() const
voidsetActivationOrder(WindowOrder order)

See alsosubWindowList().

background :QBrush

This property holds the background brush for the workspace.

This property sets the background brush for the workspace area itself. By default, it is a gray color, but can be any brush (e.g., colors, gradients or pixmaps).

Access functions:

QBrushbackground() const
voidsetBackground(const QBrush & background)

documentMode :bool

This property holds whether the tab bar is set to document mode in tabbed view mode.

Document mode is disabled by default.

This property was introduced in Qt 4.5.

Access functions:

booldocumentMode() const
voidsetDocumentMode(bool enabled)

See alsoQTabBar::documentMode andsetViewMode().

tabPosition :QTabWidget::TabPosition

This property holds the position of the tabs in tabbed view mode.

Possible values for this property are described by theQTabWidget::TabPosition enum.

This property was introduced in Qt 4.4.

Access functions:

QTabWidget::TabPositiontabPosition() const
voidsetTabPosition(QTabWidget::TabPosition position)

See alsoQTabWidget::TabPosition andsetViewMode().

tabShape :QTabWidget::TabShape

This property holds the shape of the tabs in tabbed view mode.

Possible values for this property areQTabWidget::Rounded (default) orQTabWidget::Triangular.

This property was introduced in Qt 4.4.

Access functions:

QTabWidget::TabShapetabShape() const
voidsetTabShape(QTabWidget::TabShape shape)

See alsoQTabWidget::TabShape andsetViewMode().

tabsClosable :bool

This property holds whether the tab bar should place close buttons on each tab in tabbed view mode.

Tabs are not closable by default.

This property was introduced in Qt 4.8.

Access functions:

booltabsClosable() const
voidsetTabsClosable(bool closable)

See alsoQTabBar::tabsClosable andsetViewMode().

tabsMovable :bool

This property holds whether the user can move the tabs within the tabbar area in tabbed view mode.

Tabs are not movable by default.

This property was introduced in Qt 4.8.

Access functions:

booltabsMovable() const
voidsetTabsMovable(bool movable)

See alsoQTabBar::movable andsetViewMode().

viewMode :ViewMode

This property holds the way sub-windows are displayed in the QMdiArea.

By default, theSubWindowView is used to display sub-windows.

This property was introduced in Qt 4.4.

Access functions:

ViewModeviewMode() const
voidsetViewMode(ViewMode mode)

See alsoViewMode,setTabShape(), andsetTabPosition().

Member Function Documentation

QMdiArea::QMdiArea(QWidget * parent = 0)

Constructs an empty mdi area.parent is passed toQWidget's constructor.

QMdiArea::~QMdiArea()

Destroys the MDI area.

[slot]void QMdiArea::activateNextSubWindow()

Gives the keyboard focus to another window in the list of child windows. The window activated will be the next one determined by the currentactivation order.

See alsoactivatePreviousSubWindow() andQMdiArea::WindowOrder.

[slot]void QMdiArea::activatePreviousSubWindow()

Gives the keyboard focus to another window in the list of child windows. The window activated will be the previous one determined by the currentactivation order.

See alsoactivateNextSubWindow() andQMdiArea::WindowOrder.

QMdiSubWindow * QMdiArea::activeSubWindow() const

Returns a pointer to the current active subwindow. If no window is currently active, 0 is returned.

Subwindows are treated as top-level windows with respect to window state, i.e., if a widget outside the MDI area is the active window, no subwindow will be active. Note that if a widget in the window in which the MDI area lives gains focus, the window will be activated.

See alsosetActiveSubWindow() andQt::WindowState.

QMdiSubWindow * QMdiArea::addSubWindow(QWidget * widget,Qt::WindowFlags windowFlags = 0)

Addswidget as a new subwindow to the MDI area. IfwindowFlags are non-zero, they will override the flags set on the widget.

Thewidget can be either aQMdiSubWindow or anotherQWidget (in which case the MDI area will create a subwindow and set thewidget as the internal widget).

Note:Once the subwindow has been added, its parent will be theviewport widget of theQMdiArea.

QMdiArea mdiArea;QMdiSubWindow*subWindow1=newQMdiSubWindow;    subWindow1->setWidget(internalWidget1);    subWindow1->setAttribute(Qt::WA_DeleteOnClose);    mdiArea.addSubWindow(subWindow1);QMdiSubWindow*subWindow2=        mdiArea.addSubWindow(internalWidget2);

When you create your own subwindow, you must set theQt::WA_DeleteOnClose widget attribute if you want the window to be deleted when closed in the MDI area. If not, the window will be hidden and the MDI area will not activate the next subwindow.

Returns theQMdiSubWindow that is added to the MDI area.

See alsoremoveSubWindow().

[slot]void QMdiArea::cascadeSubWindows()

Arranges all the child windows in a cascade pattern.

See alsotileSubWindows().

[virtual protected]void QMdiArea::childEvent(QChildEvent * childEvent)

Reimplemented fromQObject::childEvent().

[slot]void QMdiArea::closeActiveSubWindow()

Closes the active subwindow.

See alsocloseAllSubWindows().

[slot]void QMdiArea::closeAllSubWindows()

Closes all subwindows by sending aQCloseEvent to each window. You may receivesubWindowActivated() signals from subwindows before they are closed (if the MDI area activates the subwindow when another is closing).

Subwindows that ignore the close event will remain open.

See alsocloseActiveSubWindow().

QMdiSubWindow * QMdiArea::currentSubWindow() const

Returns a pointer to the current subwindow, or 0 if there is no current subwindow.

This function will return the same asactiveSubWindow() if theQApplication containingQMdiArea is active.

See alsoactiveSubWindow() andQApplication::activeWindow().

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

Reimplemented fromQObject::event().

[virtual protected]bool QMdiArea::eventFilter(QObject * object,QEvent * event)

Reimplemented fromQObject::eventFilter().

[virtual]QSize QMdiArea::minimumSizeHint() const

Reimplemented fromQWidget::minimumSizeHint().

[virtual protected]void QMdiArea::paintEvent(QPaintEvent * paintEvent)

Reimplemented fromQWidget::paintEvent().

void QMdiArea::removeSubWindow(QWidget * widget)

Removeswidget from the MDI area. Thewidget must be either aQMdiSubWindow or a widget that is the internal widget of a subwindow. Notewidget is never actually deleted byQMdiArea. If aQMdiSubWindow is passed in its parent is set to 0 and it is removed, but if an internal widget is passed in the child widget is set to 0 but theQMdiSubWindow is not removed.

See alsoaddSubWindow().

[virtual protected]void QMdiArea::resizeEvent(QResizeEvent * resizeEvent)

Reimplemented fromQWidget::resizeEvent().

[virtual protected]void QMdiArea::scrollContentsBy(int dx,int dy)

Reimplemented fromQAbstractScrollArea::scrollContentsBy().

[slot]void QMdiArea::setActiveSubWindow(QMdiSubWindow * window)

Activates the subwindowwindow. Ifwindow is 0, any current active window is deactivated.

See alsoactiveSubWindow().

void QMdiArea::setOption(AreaOption option,bool on = true)

Ifon is true,option is enabled on the MDI area; otherwise it is disabled. SeeAreaOption for the effect of each option.

See alsoAreaOption andtestOption().

[protected slot]void QMdiArea::setupViewport(QWidget * viewport)

This slot is called byQAbstractScrollArea aftersetViewport() has been called. Reimplement this function in a subclass ofQMdiArea to initialize the newviewport before it is used.

See alsosetViewport().

[virtual protected]void QMdiArea::showEvent(QShowEvent * showEvent)

Reimplemented fromQWidget::showEvent().

[virtual]QSize QMdiArea::sizeHint() const

Reimplemented fromQWidget::sizeHint().

[signal]void QMdiArea::subWindowActivated(QMdiSubWindow * window)

QMdiArea emits this signal afterwindow has been activated. Whenwindow is 0,QMdiArea has just deactivated its last active window, and there are no active windows on the workspace.

See alsoQMdiArea::activeSubWindow().

QList<QMdiSubWindow *> QMdiArea::subWindowList(WindowOrder order = CreationOrder) const

Returns a list of all subwindows in the MDI area. Iforder isCreationOrder (the default), the windows are sorted in the order in which they were inserted into the workspace. Iforder isStackingOrder, the windows are listed in their stacking order, with the topmost window as the last item in the list. Iforder isActivationHistoryOrder, the windows are listed according to their recent activation history.

See alsoWindowOrder.

bool QMdiArea::testOption(AreaOption option) const

Returns true ifoption is enabled; otherwise returns false.

See alsoAreaOption andsetOption().

[slot]void QMdiArea::tileSubWindows()

Arranges all child windows in a tile pattern.

See alsocascadeSubWindows().

[virtual protected]void QMdiArea::timerEvent(QTimerEvent * timerEvent)

Reimplemented fromQObject::timerEvent().

[virtual protected]bool QMdiArea::viewportEvent(QEvent * event)

Reimplemented fromQAbstractScrollArea::viewportEvent().

© 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