Qt 4.8
Public Types | Public Slots | Signals | Public Functions | Protected Slots | Protected Functions | Properties | List of all members
QMdiArea Class Reference

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

#include <qmdiarea.h>

Inheritance diagram for QMdiArea:
QAbstractScrollArea QFrame QWidget QObject QPaintDevice

Public Types

enum  AreaOption { DontMaximizeSubWindowOnActivation = 0x1 }
 This enum describes options that customize the behavior of the QMdiArea. More...
 
enum  ViewMode { SubWindowView, TabbedView }
 This enum describes the view mode of the area; i. More...
 
enum  WindowOrder { CreationOrder, StackingOrder, ActivationHistoryOrder }
 Specifies the criteria to use for ordering the list of child windows returned by subWindowList(). More...
 
- Public Types inherited from QFrame
enum  Shadow { Plain = 0x0010, Raised = 0x0020, Sunken = 0x0030 }
 This enum type defines the types of shadow that are used to give a 3D effect to frames. More...
 
enum  Shape {
  NoFrame = 0, Box = 0x0001, Panel = 0x0002, WinPanel = 0x0003,
  HLine = 0x0004, VLine = 0x0005, StyledPanel = 0x0006
}
 This enum type defines the shapes of frame available. More...
 
enum  StyleMask { Shadow_Mask = 0x00f0, Shape_Mask = 0x000f }
 This enum defines two constants that can be used to extract the two components of frameStyle(): More...
 
- Public Types inherited from QWidget
enum  RenderFlag { DrawWindowBackground = 0x1, DrawChildren = 0x2, IgnoreMask = 0x4 }
 This enum describes how to render the widget when calling QWidget::render(). More...
 
- Public Types inherited from QPaintDevice
enum  PaintDeviceMetric {
  PdmWidth = 1, PdmHeight, PdmWidthMM, PdmHeightMM,
  PdmNumColors, PdmDepth, PdmDpiX, PdmDpiY,
  PdmPhysicalDpiX, PdmPhysicalDpiY
}
 

Public Slots

void activateNextSubWindow ()
 Gives the keyboard focus to another window in the list of child windows. More...
 
void activatePreviousSubWindow ()
 Gives the keyboard focus to another window in the list of child windows. More...
 
void cascadeSubWindows ()
 Arranges all the child windows in a cascade pattern. More...
 
void closeActiveSubWindow ()
 Closes the active subwindow. More...
 
void closeAllSubWindows ()
 Closes all subwindows by sending a QCloseEvent to each window. More...
 
void setActiveSubWindow (QMdiSubWindow *window)
 Activates the subwindow window. More...
 
void tileSubWindows ()
 Arranges all child windows in a tile pattern. More...
 
- Public Slots inherited from QWidget
bool close ()
 Closes this widget. More...
 
void hide ()
 Hides the widget. More...
 
void lower ()
 Lowers the widget to the bottom of the parent widget's stack. More...
 
void raise ()
 Raises this widget to the top of the parent widget's stack. More...
 
void repaint ()
 Repaints the widget directly by calling paintEvent() immediately, unless updates are disabled or the widget is hidden. More...
 
void setDisabled (bool)
 Disables widget input events if disable is true; otherwise enables input events. More...
 
void setEnabled (bool)
 
void setFocus ()
 Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its parents is the active window. More...
 
void setHidden (bool hidden)
 Convenience function, equivalent to setVisible(!hidden). More...
 
QT_MOC_COMPAT void setShown (bool shown)
 Use setVisible(shown) instead. More...
 
void setStyleSheet (const QString &styleSheet)
 
virtual void setVisible (bool visible)
 
void setWindowModified (bool)
 
void setWindowTitle (const QString &)
 
void show ()
 Shows the widget and its child widgets. More...
 
void showFullScreen ()
 Shows the widget in full-screen mode. More...
 
void showMaximized ()
 Shows the widget maximized. More...
 
void showMinimized ()
 Shows the widget minimized, as an icon. More...
 
void showNormal ()
 Restores the widget after it has been maximized or minimized. More...
 
void update ()
 Updates the widget unless updates are disabled or the widget is hidden. More...
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 

Signals

void subWindowActivated (QMdiSubWindow *)
 QMdiArea emits this signal after window has been activated. More...
 
- Signals inherited from QWidget
void customContextMenuRequested (const QPoint &pos)
 This signal is emitted when the widget's contextMenuPolicy is Qt::CustomContextMenu, and the user has requested a context menu on the widget. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 

Public Functions

WindowOrder activationOrder () const
 
QMdiSubWindowactiveSubWindow () const
 Returns a pointer to the current active subwindow. More...
 
QMdiSubWindowaddSubWindow (QWidget *widget, Qt::WindowFlags flags=0)
 Adds widget as a new subwindow to the MDI area. More...
 
QBrush background () const
 
QMdiSubWindowcurrentSubWindow () const
 Returns a pointer to the current subwindow, or 0 if there is no current subwindow. More...
 
bool documentMode () const
 
QSize minimumSizeHint () const
 Reimplemented Function More...
 
 QMdiArea (QWidget *parent=0)
 Constructs an empty mdi area. More...
 
void removeSubWindow (QWidget *widget)
 Removes widget from the MDI area. More...
 
void setActivationOrder (WindowOrder order)
 
void setBackground (const QBrush &background)
 
void setDocumentMode (bool enabled)
 
void setOption (AreaOption option, bool on=true)
 If on is true, option is enabled on the MDI area; otherwise it is disabled. More...
 
void setTabPosition (QTabWidget::TabPosition position)
 
void setTabsClosable (bool closable)
 
void setTabShape (QTabWidget::TabShape shape)
 
void setTabsMovable (bool movable)
 
void setViewMode (ViewMode mode)
 
QSize sizeHint () const
 Reimplemented Function More...
 
QList< QMdiSubWindow * > subWindowList (WindowOrder order=CreationOrder) const
 Returns a list of all subwindows in the MDI area. More...
 
QTabWidget::TabPosition tabPosition () const
 
bool tabsClosable () const
 
QTabWidget::TabShape tabShape () const
 
bool tabsMovable () const
 
bool testOption (AreaOption opton) const
 Returns true if option is enabled; otherwise returns false. More...
 
ViewMode viewMode () const
 
 ~QMdiArea ()
 Destroys the MDI area. More...
 
- Public Functions inherited from QAbstractScrollArea
void addScrollBarWidget (QWidget *widget, Qt::Alignment alignment)
 Adds widget as a scroll bar widget in the location specified by alignment. More...
 
QWidgetcornerWidget () const
 Returns the widget in the corner between the two scroll bars. More...
 
QScrollBarhorizontalScrollBar () const
 Returns the horizontal scroll bar. More...
 
Qt::ScrollBarPolicy horizontalScrollBarPolicy () const
 
QSize maximumViewportSize () const
 Returns the size of the viewport as if the scroll bars had no valid scrolling range. More...
 
 QAbstractScrollArea (QWidget *parent=0)
 Constructs a viewport. More...
 
QWidgetList scrollBarWidgets (Qt::Alignment alignment)
 Returns a list of the currently set scroll bar widgets. More...
 
void setCornerWidget (QWidget *widget)
 Sets the widget in the corner between the two scroll bars to be widget. More...
 
void setHorizontalScrollBar (QScrollBar *scrollbar)
 Replaces the existing horizontal scroll bar with scrollBar, and sets all the former scroll bar's slider properties on the new scroll bar. More...
 
void setHorizontalScrollBarPolicy (Qt::ScrollBarPolicy)
 
void setVerticalScrollBar (QScrollBar *scrollbar)
 Replaces the existing vertical scroll bar with scrollBar, and sets all the former scroll bar's slider properties on the new scroll bar. More...
 
void setVerticalScrollBarPolicy (Qt::ScrollBarPolicy)
 
void setViewport (QWidget *widget)
 Sets the viewport to be the given widget. More...
 
QScrollBarverticalScrollBar () const
 Returns the vertical scroll bar. More...
 
Qt::ScrollBarPolicy verticalScrollBarPolicy () const
 
QWidgetviewport () const
 Returns the viewport widget. More...
 
 ~QAbstractScrollArea ()
 Destroys the viewport. More...
 
- Public Functions inherited from QFrame
QRect frameRect () const
 
Shadow frameShadow () const
 
Shape frameShape () const
 
int frameStyle () const
 Returns the frame style. More...
 
int frameWidth () const
 
int lineWidth () const
 
int midLineWidth () const
 
 QFrame (QWidget *parent=0, Qt::WindowFlags f=0)
 Constructs a frame widget with frame style NoFrame and a 1-pixel frame width. More...
 
void setFrameRect (const QRect &)
 em>Reimplemented Function More...
 
void setFrameShadow (Shadow)
 
void setFrameShape (Shape)
 
void setFrameStyle (int)
 Sets the frame style to style. More...
 
void setLineWidth (int)
 
void setMidLineWidth (int)
 
 ~QFrame ()
 Destroys the frame. More...
 
- Public Functions inherited from QWidget
bool acceptDrops () const
 
QString accessibleDescription () const
 
QString accessibleName () const
 
QList< QAction * > actions () const
 Returns the (possibly empty) list of this widget's actions. More...
 
void activateWindow ()
 Sets the top-level widget containing this widget to be the active window. More...
 
void addAction (QAction *action)
 Appends the action action to this widget's list of actions. More...
 
void addActions (QList< QAction *> actions)
 Appends the actions actions to this widget's list of actions. More...
 
void adjustSize ()
 Adjusts the size of the widget to fit its contents. More...
 
bool autoFillBackground () const
 
QPalette::ColorRole backgroundRole () const
 Returns the background role of the widget. More...
 
QSize baseSize () const
 
QWidgetchildAt (int x, int y) const
 Returns the visible child widget at the position ({x}, {y}) in the widget's coordinate system. More...
 
QWidgetchildAt (const QPoint &p) const
 Returns the visible child widget at point p in the widget's own coordinate system. More...
 
QRect childrenRect () const
 
QRegion childrenRegion () const
 
void clearFocus ()
 Takes keyboard input focus from the widget. More...
 
void clearMask ()
 Removes any mask set by setMask(). More...
 
QMargins contentsMargins () const
 The contentsMargins function returns the widget's contents margins. More...
 
QRect contentsRect () const
 Returns the area inside the widget's margins. More...
 
Qt::ContextMenuPolicy contextMenuPolicy () const
 
void createWinId ()
 
QCursor cursor () const
 
int devType () const
 
WId effectiveWinId () const
 Returns the effective window system identifier of the widget, i. More...
 
void ensurePolished () const
 Ensures that the widget has been polished by QStyle (i.e., has a proper font and palette). More...
 
Qt::FocusPolicy focusPolicy () const
 
QWidgetfocusProxy () const
 Returns the focus proxy, or 0 if there is no focus proxy. More...
 
QWidgetfocusWidget () const
 Returns the last child of this widget that setFocus had been called on. More...
 
const QFontfont () const
 
QFontInfo fontInfo () const
 Returns the font info for the widget's current font. More...
 
QFontMetrics fontMetrics () const
 Returns the font metrics for the widget's current font. More...
 
QPalette::ColorRole foregroundRole () const
 Returns the foreground role. More...
 
QRect frameGeometry () const
 
QSize frameSize () const
 
const QRectgeometry () const
 
void getContentsMargins (int *left, int *top, int *right, int *bottom) const
 Returns the widget's contents margins for left, top, right, and bottom. More...
 
HDC getDC () const
 Returns the window system handle of the widget, for low-level access. More...
 
void grabGesture (Qt::GestureType type, Qt::GestureFlags flags=Qt::GestureFlags())
 Subscribes the widget to a given gesture with specific flags. More...
 
void grabKeyboard ()
 Grabs the keyboard input. More...
 
void grabMouse ()
 Grabs the mouse input. More...
 
void grabMouse (const QCursor &)
 
int grabShortcut (const QKeySequence &key, Qt::ShortcutContext context=Qt::WindowShortcut)
 Adds a shortcut to Qt's shortcut system that watches for the given key sequence in the given context. More...
 
QGraphicsEffectgraphicsEffect () const
 The graphicsEffect function returns a pointer to the widget's graphics effect. More...
 
QGraphicsProxyWidgetgraphicsProxyWidget () const
 Returns the proxy widget for the corresponding embedded widget in a graphics view; otherwise returns 0. More...
 
bool hasFocus () const
 
bool hasMouseTracking () const
 
int height () const
 
virtual int heightForWidth (int) const
 Returns the preferred height for this widget, given the width w. More...
 
QInputContextinputContext ()
 This function returns the QInputContext for this widget. More...
 
Qt::InputMethodHints inputMethodHints () const
 
virtual QVariant inputMethodQuery (Qt::InputMethodQuery) const
 This method is only relevant for input widgets. More...
 
void insertAction (QAction *before, QAction *action)
 Inserts the action action to this widget's list of actions, before the action before. More...
 
void insertActions (QAction *before, QList< QAction *> actions)
 Inserts the actions actions to this widget's list of actions, before the action before. More...
 
WId internalWinId () const
 Returns the window system identifier of the widget, or 0 if the widget is not created yet. More...
 
bool isActiveWindow () const
 
bool isAncestorOf (const QWidget *child) const
 Returns true if this widget is a parent, (or grandparent and so on to any level), of the given child, and both widgets are within the same window; otherwise returns false. More...
 
bool isEnabled () const
 
bool isEnabledTo (QWidget *) const
 Returns true if this widget would become enabled if ancestor is enabled; otherwise returns false. More...
 
bool isEnabledToTLW () const
 This function is deprecated. More...
 
bool isFullScreen () const
 
bool isHidden () const
 Returns true if the widget is hidden, otherwise returns false. More...
 
bool isLeftToRight () const
 
bool isMaximized () const
 
bool isMinimized () const
 
bool isModal () const
 
bool isRightToLeft () const
 
bool isTopLevel () const
 Use isWindow() instead. More...
 
bool isVisible () const
 
bool isVisibleTo (QWidget *) const
 Returns true if this widget would become visible if ancestor is shown; otherwise returns false. More...
 
bool isWindow () const
 Returns true if the widget is an independent window, otherwise returns false. More...
 
bool isWindowModified () const
 
QLayoutlayout () const
 Returns the layout manager that is installed on this widget, or 0 if no layout manager is installed. More...
 
Qt::LayoutDirection layoutDirection () const
 
QLocale locale () const
 
Qt::HANDLE macCGHandle () const
 Returns the CoreGraphics handle of the widget. More...
 
Qt::HANDLE macQDHandle () const
 Returns the QuickDraw handle of the widget. More...
 
QPoint mapFrom (QWidget *, const QPoint &) const
 Translates the widget coordinate pos from the coordinate system of parent to this widget's coordinate system. More...
 
QPoint mapFromGlobal (const QPoint &) const
 Translates the global screen coordinate pos to widget coordinates. More...
 
QPoint mapFromParent (const QPoint &) const
 Translates the parent widget coordinate pos to widget coordinates. More...
 
QPoint mapTo (QWidget *, const QPoint &) const
 Translates the widget coordinate pos to the coordinate system of parent. More...
 
QPoint mapToGlobal (const QPoint &) const
 Translates the widget coordinate pos to global screen coordinates. More...
 
QPoint mapToParent (const QPoint &) const
 Translates the widget coordinate pos to a coordinate in the parent widget. More...
 
QRegion mask () const
 Returns the mask currently set on a widget. More...
 
int maximumHeight () const
 
QSize maximumSize () const
 
int maximumWidth () const
 
int minimumHeight () const
 
QSize minimumSize () const
 
int minimumWidth () const
 
void move (int x, int y)
 This corresponds to move(QPoint(x, y)). More...
 
void move (const QPoint &)
 
QWidgetnativeParentWidget () const
 Returns the native parent for this widget, i. More...
 
QWidgetnextInFocusChain () const
 Returns the next widget in this widget's focus chain. More...
 
QRect normalGeometry () const
 
void overrideWindowFlags (Qt::WindowFlags type)
 Sets the window flags for the widget to flags, without telling the window system. More...
 
void overrideWindowState (Qt::WindowStates state)
 
QPaintEnginepaintEngine () const
 Returns the widget's paint engine. More...
 
const QPalettepalette () const
 
QWidgetparentWidget () const
 Returns the parent of this widget, or 0 if it does not have any parent widget. More...
 
QPoint pos () const
 
QWidgetpreviousInFocusChain () const
 The previousInFocusChain function returns the previous widget in this widget's focus chain. More...
 
 QWidget (QWidget *parent=0, Qt::WindowFlags f=0)
 Constructs a widget which is a child of parent, with widget flags set to f. More...
 
QRect rect () const
 
void releaseDC (HDC) const
 Releases the HDC hdc acquired by a previous call to getDC(). More...
 
void releaseKeyboard ()
 Releases the keyboard grab. More...
 
void releaseMouse ()
 Releases the mouse grab. More...
 
void releaseShortcut (int id)
 Removes the shortcut with the given id from Qt's shortcut system. More...
 
void removeAction (QAction *action)
 Removes the action action from this widget's list of actions. More...
 
void render (QPaintDevice *target, const QPoint &targetOffset=QPoint(), const QRegion &sourceRegion=QRegion(), RenderFlags renderFlags=RenderFlags(DrawWindowBackground|DrawChildren))
 Renders the sourceRegion of this widget into the target using renderFlags to determine how to render. More...
 
void render (QPainter *painter, const QPoint &targetOffset=QPoint(), const QRegion &sourceRegion=QRegion(), RenderFlags renderFlags=RenderFlags(DrawWindowBackground|DrawChildren))
 Renders the widget into the painter's QPainter::device(). More...
 
void repaint (int x, int y, int w, int h)
 This version repaints a rectangle (x, y, w, h) inside the widget. More...
 
void repaint (const QRect &)
 This version repaints a rectangle rect inside the widget. More...
 
void repaint (const QRegion &)
 This version repaints a region rgn inside the widget. More...
 
void resize (int w, int h)
 This corresponds to resize(QSize(w, h)). More...
 
void resize (const QSize &)
 
bool restoreGeometry (const QByteArray &geometry)
 Restores the geometry and state top-level widgets stored in the byte array geometry. More...
 
QByteArray saveGeometry () const
 Saves the current geometry and state for top-level widgets. More...
 
void scroll (int dx, int dy)
 Scrolls the widget including its children dx pixels to the right and dy downward. More...
 
void scroll (int dx, int dy, const QRect &)
 This version only scrolls r and does not move the children of the widget. More...
 
void setAcceptDrops (bool on)
 
void setAccessibleDescription (const QString &description)
 
void setAccessibleName (const QString &name)
 
void setAttribute (Qt::WidgetAttribute, bool on=true)
 Sets the attribute attribute on this widget if on is true; otherwise clears the attribute. More...
 
void setAutoFillBackground (bool enabled)
 
void setBackgroundRole (QPalette::ColorRole)
 Sets the background role of the widget to role. More...
 
void setBaseSize (const QSize &)
 
void setBaseSize (int basew, int baseh)
 This corresponds to setBaseSize(QSize(basew, baseh)). More...
 
void setContentsMargins (int left, int top, int right, int bottom)
 Sets the margins around the contents of the widget to have the sizes left, top, right, and bottom. More...
 
void setContentsMargins (const QMargins &margins)
 The setContentsMargins function sets the margins around the widget's contents. More...
 
void setContextMenuPolicy (Qt::ContextMenuPolicy policy)
 
void setCursor (const QCursor &)
 
void setFixedHeight (int h)
 Sets both the minimum and maximum heights of the widget to h without changing the widths. More...
 
void setFixedSize (const QSize &)
 Sets both the minimum and maximum sizes of the widget to s, thereby preventing it from ever growing or shrinking. More...
 
void setFixedSize (int w, int h)
 Sets the width of the widget to w and the height to h. More...
 
void setFixedWidth (int w)
 Sets both the minimum and maximum width of the widget to w without changing the heights. More...
 
void setFocus (Qt::FocusReason reason)
 Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its parents is the active window. More...
 
void setFocusPolicy (Qt::FocusPolicy policy)
 
void setFocusProxy (QWidget *)
 Sets the widget's focus proxy to widget w. More...
 
void setFont (const QFont &)
 Use the single-argument overload instead. More...
 
void setForegroundRole (QPalette::ColorRole)
 Sets the foreground role of the widget to role. More...
 
void setGeometry (int x, int y, int w, int h)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.This corresponds to setGeometry(QRect(x, y, w, h)). More...
 
void setGeometry (const QRect &)
 
void setGraphicsEffect (QGraphicsEffect *effect)
 The setGraphicsEffect function is for setting the widget's graphics effect. More...
 
void setInputContext (QInputContext *)
 This function sets the input context context on this widget. More...
 
void setInputMethodHints (Qt::InputMethodHints hints)
 
void setLayout (QLayout *)
 Sets the layout manager for this widget to layout. More...
 
void setLayoutDirection (Qt::LayoutDirection direction)
 
void setLocale (const QLocale &locale)
 
void setMask (const QBitmap &)
 Causes only the pixels of the widget for which bitmap has a corresponding 1 bit to be visible. More...
 
void setMask (const QRegion &)
 Causes only the parts of the widget which overlap region to be visible. More...
 
void setMaximumHeight (int maxh)
 
void setMaximumSize (const QSize &)
 
void setMaximumSize (int maxw, int maxh)
 This function corresponds to setMaximumSize(QSize(maxw, maxh)). More...
 
void setMaximumWidth (int maxw)
 
void setMinimumHeight (int minh)
 
void setMinimumSize (const QSize &)
 
void setMinimumSize (int minw, int minh)
 This function corresponds to setMinimumSize(QSize(minw, minh)). More...
 
void setMinimumWidth (int minw)
 
void setMouseTracking (bool enable)
 
void setPalette (const QPalette &)
 Use the single-argument overload instead. More...
 
void setParent (QWidget *parent)
 Sets the parent of the widget to parent, and resets the window flags. More...
 
void setParent (QWidget *parent, Qt::WindowFlags f)
 This function also takes widget flags, f as an argument. More...
 
void setShortcutAutoRepeat (int id, bool enable=true)
 If enable is true, auto repeat of the shortcut with the given id is enabled; otherwise it is disabled. More...
 
void setShortcutEnabled (int id, bool enable=true)
 If enable is true, the shortcut with the given id is enabled; otherwise the shortcut is disabled. More...
 
void setSizeIncrement (const QSize &)
 
void setSizeIncrement (int w, int h)
 Sets the x (width) size increment to w and the y (height) size increment to h. More...
 
void setSizePolicy (QSizePolicy)
 
void setSizePolicy (QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical)
 Sets the size policy of the widget to horizontal and vertical, with standard stretch and no height-for-width. More...
 
void setStatusTip (const QString &)
 
void setStyle (QStyle *)
 Sets the widget's GUI style to style. More...
 
void setToolTip (const QString &)
 
void setUpdatesEnabled (bool enable)
 
void setupUi (QWidget *widget)
 Sets up the user interface for the specified widget. More...
 
void setWhatsThis (const QString &)
 
void setWindowFilePath (const QString &filePath)
 
void setWindowFlags (Qt::WindowFlags type)
 
void setWindowIcon (const QIcon &icon)
 
void setWindowIconText (const QString &)
 
void setWindowModality (Qt::WindowModality windowModality)
 
void setWindowOpacity (qreal level)
 
void setWindowRole (const QString &)
 Sets the window's role to role. More...
 
void setWindowState (Qt::WindowStates state)
 Sets the window state to windowState. More...
 
void setWindowSurface (QWindowSurface *surface)
 Sets the window surface to be the surface specified. More...
 
QSize size () const
 
QSize sizeIncrement () const
 
QSizePolicy sizePolicy () const
 
void stackUnder (QWidget *)
 Places the widget under w in the parent widget's stack. More...
 
QString statusTip () const
 
QStylestyle () const
 
QString styleSheet () const
 
bool testAttribute (Qt::WidgetAttribute) const
 Returns true if attribute attribute is set on this widget; otherwise returns false. More...
 
QString toolTip () const
 
QWidgettopLevelWidget () const
 
bool underMouse () const
 Returns true if the widget is under the mouse cursor; otherwise returns false. More...
 
void ungrabGesture (Qt::GestureType type)
 Unsubscribes the widget from a given gesture type. More...
 
void unsetCursor ()
 
void unsetLayoutDirection ()
 
void unsetLocale ()
 
void update (int x, int y, int w, int h)
 This version updates a rectangle (x, y, w, h) inside the widget. More...
 
void update (const QRect &)
 This version updates a rectangle rect inside the widget. More...
 
void update (const QRegion &)
 This version repaints a region rgn inside the widget. More...
 
void updateGeometry ()
 Notifies the layout system that this widget has changed and may need to change geometry. More...
 
bool updatesEnabled () const
 
QRegion visibleRegion () const
 Returns the unobscured region where paint events can occur. More...
 
QString whatsThis () const
 
int width () const
 
QWidgetwindow () const
 Returns the window for this widget, i.e. More...
 
QString windowFilePath () const
 
Qt::WindowFlags windowFlags () const
 Window flags are a combination of a type (e. More...
 
QIcon windowIcon () const
 
QString windowIconText () const
 
Qt::WindowModality windowModality () const
 
qreal windowOpacity () const
 
QString windowRole () const
 Returns the window's role, or an empty string. More...
 
Qt::WindowStates windowState () const
 Returns the current window state. More...
 
QWindowSurfacewindowSurface () const
 Returns the QWindowSurface this widget will be drawn into. More...
 
QString windowTitle () const
 
Qt::WindowType windowType () const
 Returns the window type of this widget. More...
 
WId winId () const
 Returns the window system identifier of the widget. More...
 
int x () const
 
const QX11Infox11Info () const
 Returns information about the configuration of the X display used to display the widget. More...
 
Qt::HANDLE x11PictureHandle () const
 Returns the X11 Picture handle of the widget for XRender support. More...
 
int y () const
 
 ~QWidget ()
 Destroys the widget. More...
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 
- Public Functions inherited from QPaintDevice
int colorCount () const
 
int depth () const
 
int height () const
 
int heightMM () const
 
int logicalDpiX () const
 
int logicalDpiY () const
 
QT_DEPRECATED int numColors () const
 
bool paintingActive () const
 
int physicalDpiX () const
 
int physicalDpiY () const
 
int width () const
 
int widthMM () const
 
virtual ~QPaintDevice ()
 

Protected Slots

void setupViewport (QWidget *viewport)
 This slot is called by QAbstractScrollArea after setViewport() has been called. More...
 
- Protected Slots inherited from QAbstractScrollArea
void setupViewport (QWidget *viewport)
 This slot is called by QAbstractScrollArea after setViewport(viewport) has been called. More...
 
- Protected Slots inherited from QWidget
void updateMicroFocus ()
 Updates the widget's micro focus. More...
 

Protected Functions

void childEvent (QChildEvent *childEvent)
 Reimplemented Function More...
 
bool event (QEvent *event)
 Reimplemented Function More...
 
bool eventFilter (QObject *object, QEvent *event)
 Reimplemented Function More...
 
void paintEvent (QPaintEvent *paintEvent)
 Reimplemented Function More...
 
void resizeEvent (QResizeEvent *resizeEvent)
 Reimplemented Function More...
 
void scrollContentsBy (int dx, int dy)
 Reimplemented Function More...
 
void showEvent (QShowEvent *showEvent)
 Reimplemented Function More...
 
void timerEvent (QTimerEvent *timerEvent)
 Reimplemented Function More...
 
bool viewportEvent (QEvent *event)
 Reimplemented Function More...
 
- Protected Functions inherited from QAbstractScrollArea
void contextMenuEvent (QContextMenuEvent *)
 This event handler can be reimplemented in a subclass to receive context menu events for the viewport() widget. More...
 
void dragEnterEvent (QDragEnterEvent *)
 This event handler can be reimplemented in a subclass to receive drag enter events (passed in event), for the viewport() widget. More...
 
void dragLeaveEvent (QDragLeaveEvent *)
 This event handler can be reimplemented in a subclass to receive drag leave events (passed in event), for the viewport() widget. More...
 
void dragMoveEvent (QDragMoveEvent *)
 This event handler can be reimplemented in a subclass to receive drag move events (passed in event), for the viewport() widget. More...
 
void dropEvent (QDropEvent *)
 This event handler can be reimplemented in a subclass to receive drop events (passed in event), for the viewport() widget. More...
 
void keyPressEvent (QKeyEvent *)
 This function is called with key event e when key presses occur. More...
 
void mouseDoubleClickEvent (QMouseEvent *)
 This event handler can be reimplemented in a subclass to receive mouse double click events for the viewport() widget. More...
 
void mouseMoveEvent (QMouseEvent *)
 This event handler can be reimplemented in a subclass to receive mouse move events for the viewport() widget. More...
 
void mousePressEvent (QMouseEvent *)
 This event handler can be reimplemented in a subclass to receive mouse press events for the viewport() widget. More...
 
void mouseReleaseEvent (QMouseEvent *)
 This event handler can be reimplemented in a subclass to receive mouse release events for the viewport() widget. More...
 
 QAbstractScrollArea (QAbstractScrollAreaPrivate &dd, QWidget *parent=0)
 Creates a new QAbstractScrollAreaPrivate, dd with the given parent. More...
 
void setViewportMargins (int left, int top, int right, int bottom)
 Sets the margins around the scrolling area to left, top, right and bottom. More...
 
void setViewportMargins (const QMargins &margins)
 Sets margins around the scrolling area. More...
 
void wheelEvent (QWheelEvent *)
 This event handler can be reimplemented in a subclass to receive wheel events for the viewport() widget. More...
 
- Protected Functions inherited from QFrame
void changeEvent (QEvent *)
 This event handler can be reimplemented to handle state changes. More...
 
void drawFrame (QPainter *)
 em>Reimplemented Function More...
 
 QFrame (QFramePrivate &dd, QWidget *parent=0, Qt::WindowFlags f=0)
 
- Protected Functions inherited from QWidget
virtual void actionEvent (QActionEvent *)
 This event handler is called with the given event whenever the widget's actions are changed. More...
 
virtual void closeEvent (QCloseEvent *)
 This event handler is called with the given event when Qt receives a window close request for a top-level widget from the window system. More...
 
void create (WId=0, bool initializeWindow=true, bool destroyOldWindow=true)
 Creates a new widget window if window is 0, otherwise sets the widget's window to window. More...
 
void destroy (bool destroyWindow=true, bool destroySubWindows=true)
 Frees up window system resources. More...
 
virtual void enabledChange (bool)
 
virtual void enterEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive widget enter events which are passed in the event parameter. More...
 
virtual void focusInEvent (QFocusEvent *)
 This event handler can be reimplemented in a subclass to receive keyboard focus events (focus received) for the widget. More...
 
bool focusNextChild ()
 Finds a new widget to give the keyboard focus to, as appropriate for Tab, and returns true if it can find a new widget, or false if it can't. More...
 
virtual bool focusNextPrevChild (bool next)
 Finds a new widget to give the keyboard focus to, as appropriate for Tab and Shift+Tab, and returns true if it can find a new widget, or false if it can't. More...
 
virtual void focusOutEvent (QFocusEvent *)
 This event handler can be reimplemented in a subclass to receive keyboard focus events (focus lost) for the widget. More...
 
bool focusPreviousChild ()
 Finds a new widget to give the keyboard focus to, as appropriate for Shift+Tab, and returns true if it can find a new widget, or false if it can't. More...
 
virtual void fontChange (const QFont &)
 
virtual void hideEvent (QHideEvent *)
 This event handler can be reimplemented in a subclass to receive widget hide events. More...
 
virtual void inputMethodEvent (QInputMethodEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive Input Method composition events. More...
 
virtual void keyReleaseEvent (QKeyEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive key release events for the widget. More...
 
virtual void languageChange ()
 
virtual void leaveEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive widget leave events which are passed in the event parameter. More...
 
virtual bool macEvent (EventHandlerCallRef, EventRef)
 This special event handler can be reimplemented in a subclass to receive native Macintosh events. More...
 
int metric (PaintDeviceMetric) const
 Internal implementation of the virtual QPaintDevice::metric() function. More...
 
virtual void moveEvent (QMoveEvent *)
 This event handler can be reimplemented in a subclass to receive widget move events which are passed in the event parameter. More...
 
virtual void paletteChange (const QPalette &)
 
 QWidget (QWidgetPrivate &d, QWidget *parent, Qt::WindowFlags f)
 
virtual bool qwsEvent (QWSEvent *)
 This special event handler can be reimplemented in a subclass to receive native Qt for Embedded Linux events which are passed in the event parameter. More...
 
void resetInputContext ()
 This function can be called on the widget that currently has focus to reset the input method operating on it. More...
 
virtual void styleChange (QStyle &)
 
virtual void tabletEvent (QTabletEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive tablet events for the widget. More...
 
virtual void windowActivationChange (bool)
 
virtual bool winEvent (MSG *message, long *result)
 This special event handler can be reimplemented in a subclass to receive native Windows events which are passed in the message parameter. More...
 
virtual bool x11Event (XEvent *)
 This special event handler can be reimplemented in a subclass to receive native X11 events passed in the event parameter. More...
 
- Protected Functions inherited from QObject
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
- Protected Functions inherited from QPaintDevice
 QPaintDevice ()
 

Properties

WindowOrder activationOrder
 the ordering criteria for subwindow lists More...
 
QBrush background
 the background brush for the workspace More...
 
bool documentMode
 whether the tab bar is set to document mode in tabbed view mode. More...
 
QTabWidget::TabPosition tabPosition
 the position of the tabs in tabbed view mode. More...
 
bool tabsClosable
 whether the tab bar should place close buttons on each tab in tabbed view mode. More...
 
QTabWidget::TabShape tabShape
 the shape of the tabs in tabbed view mode. More...
 
bool tabsMovable
 whether the user can move the tabs within the tabbar area in tabbed view mode. More...
 
ViewMode viewMode
 the way sub-windows are displayed in the QMdiArea. More...
 

Additional Inherited Members

- Static Public Functions inherited from QWidget
static QWidgetfind (WId)
 Returns a pointer to the widget with window identifer/handle id. More...
 
static QWidgetkeyboardGrabber ()
 Returns the widget that is currently grabbing the keyboard input. More...
 
static QWidgetmouseGrabber ()
 Returns the widget that is currently grabbing the mouse input. More...
 
static void setTabOrder (QWidget *, QWidget *)
 Puts the second widget after the first widget in the focus order. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Functions inherited from QPaintDevice
static QWSDisplayqwsDisplay ()
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Protected Variables inherited from QPaintDevice
ushort painters
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

The QMdiArea widget provides an area in which MDI windows are displayed.

Since
4.3

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 a QMainWindow to create MDI applications, but can also be placed in any layout. The following code adds an area to a main window:

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

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

Subwindows in QMdiArea are instances of QMdiSubWindow. They are added to an MDI area with addSubWindow(). It is common to pass a QWidget, which is set as the internal widget, to this function, but it is also possible to pass a QMdiSubWindow directly.The class inherits QWidget, 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 the QMdiSubWindow class description for more details.

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

The convenience function subWindowList() 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 current QMdiArea::WindowOrder. This is used for the subWindowList() and for activateNextSubWindow() and acivatePreviousSubWindow(). Also, it is used when cascading or tiling the windows with cascadeSubWindows() and tileSubWindows().

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

mdi-cascade.png
mdi-tile.png
Note
The default scroll bar property for QMdiArea is Qt::ScrollBarAlwaysOff.
See also
QMdiSubWindow

Definition at line 59 of file qmdiarea.h.

Enumerations

◆ AreaOption

This enum describes options that customize the behavior of the QMdiArea.

  • DontMaximizeSubWindowOnActivation When 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.
Enumerator
DontMaximizeSubWindowOnActivation 

Definition at line 77 of file qmdiarea.h.

◆ ViewMode

This enum describes the view mode of the area; i.

Since
4.4

e. how sub-windows will be displayed.

  • SubWindowView Display sub-windows with window frames (default).
  • TabbedView Display sub-windows with tabs in a tab bar.
See also
setViewMode()
Enumerator
SubWindowView 
TabbedView 

Definition at line 88 of file qmdiarea.h.

◆ WindowOrder

Specifies the criteria to use for ordering the list of child windows returned by subWindowList().

The functions cascadeSubWindows() and tileSubWindows() follow this order when arranging the windows.

  • CreationOrder The windows are returned in the order of their creation.
  • StackingOrder The windows are returned in the order in which they are stacked, with the top-most window being last in the list.
  • ActivationHistoryOrder The windows are returned in the order in which they were activated.
See also
subWindowList()
Enumerator
CreationOrder 
StackingOrder 
ActivationHistoryOrder 

Definition at line 82 of file qmdiarea.h.

Constructors and Destructors

◆ QMdiArea()

QMdiArea::QMdiArea ( QWidget parent = 0)

Constructs an empty mdi area.

parent is passed to QWidget's constructor.

Definition at line 1715 of file qmdiarea.cpp.

1716  : QAbstractScrollArea(*new QMdiAreaPrivate, parent)
1717 {
1722  setViewport(0);
1725 }
void setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy)
const QPalette & palette() const
QAbstractScrollArea(QWidget *parent=0)
Constructs a viewport.
void setVerticalScrollBarPolicy(Qt::ScrollBarPolicy)
static QCoreApplication * instance()
Returns a pointer to the application&#39;s QCoreApplication (or QApplication) instance.
void setFrameStyle(int)
Sets the frame style to style.
Definition: qframe.cpp:329
void installEventFilter(QObject *)
Installs an event filter filterObj on this object.
Definition: qobject.cpp:2070
void setViewport(QWidget *widget)
Sets the viewport to be the given widget.
void setBackground(const QBrush &background)
Definition: qmdiarea.cpp:2079
void setFocusPolicy(Qt::FocusPolicy policy)
Definition: qwidget.cpp:7631

◆ ~QMdiArea()

QMdiArea::~QMdiArea ( )

Destroys the MDI area.

Definition at line 1730 of file qmdiarea.cpp.

1731 {
1732  Q_D(QMdiArea);
1733  delete d->cascader;
1734  d->cascader = 0;
1735 
1736  delete d->regularTiler;
1737  d->regularTiler = 0;
1738 
1739  delete d->iconTiler;
1740  d->iconTiler = 0;
1741 
1742  delete d->placer;
1743  d->placer = 0;
1744 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59

Functions

◆ activateNextSubWindow

void QMdiArea::activateNextSubWindow ( )
slot

Gives the keyboard focus to another window in the list of child windows.

The window activated will be the next one determined by the current activation order.

See also
activatePreviousSubWindow(), QMdiArea::WindowOrder

Definition at line 1927 of file qmdiarea.cpp.

1928 {
1929  Q_D(QMdiArea);
1930  if (d->childWindows.isEmpty())
1931  return;
1932 
1933  QMdiSubWindow *next = d->nextVisibleSubWindow(1, d->activationOrder);
1934  if (next)
1935  d->activateWindow(next);
1936 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59
The QMdiSubWindow class provides a subwindow class for QMdiArea.
Definition: qmdisubwindow.h:60

◆ activatePreviousSubWindow

void QMdiArea::activatePreviousSubWindow ( )
slot

Gives the keyboard focus to another window in the list of child windows.

The window activated will be the previous one determined by the current activation order.

See also
activateNextSubWindow(), QMdiArea::WindowOrder

Definition at line 1945 of file qmdiarea.cpp.

1946 {
1947  Q_D(QMdiArea);
1948  if (d->childWindows.isEmpty())
1949  return;
1950 
1951  QMdiSubWindow *previous = d->nextVisibleSubWindow(-1, d->activationOrder);
1952  if (previous)
1953  d->activateWindow(previous);
1954 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59
The QMdiSubWindow class provides a subwindow class for QMdiArea.
Definition: qmdisubwindow.h:60

◆ activationOrder()

WindowOrder QMdiArea::activationOrder ( ) const

Referenced by setBackground().

◆ activeSubWindow()

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 also
setActiveSubWindow(), Qt::WindowState

Definition at line 1832 of file qmdiarea.cpp.

Referenced by QAccessibleMdiArea::state().

1833 {
1834  Q_D(const QMdiArea);
1835  return d->active;
1836 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59

◆ addSubWindow()

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

Adds widget as a new subwindow to the MDI area.

If windowFlags are non-zero, they will override the flags set on the widget.

The widget can be either a QMdiSubWindow or another QWidget (in which case the MDI area will create a subwindow and set the widget as the internal widget).

Note
Once the subwindow has been added, its parent will be the viewport widget of the QMdiArea.
QMdiArea mdiArea;
QMdiSubWindow *subWindow1 = new QMdiSubWindow;
subWindow1->setWidget(internalWidget1);
mdiArea.addSubWindow(subWindow1);
QMdiSubWindow *subWindow2 =
mdiArea.addSubWindow(internalWidget2);

When you create your own subwindow, you must set the Qt::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 the QMdiSubWindow that is added to the MDI area.

See also
removeSubWindow()

Definition at line 1979 of file qmdiarea.cpp.

1980 {
1981  if (!widget) {
1982  qWarning("QMdiArea::addSubWindow: null pointer to widget");
1983  return 0;
1984  }
1985 
1986  Q_D(QMdiArea);
1987  // QWidget::setParent clears focusWidget so store it
1988  QWidget *childFocus = widget->focusWidget();
1990 
1991  // Widget is already a QMdiSubWindow
1992  if (child) {
1993  if (d->childWindows.indexOf(child) != -1) {
1994  qWarning("QMdiArea::addSubWindow: window is already added");
1995  return child;
1996  }
1997  child->setParent(viewport(), windowFlags ? windowFlags : child->windowFlags());
1998  // Create a QMdiSubWindow
1999  } else {
2000  child = new QMdiSubWindow(viewport(), windowFlags);
2002  child->setWidget(widget);
2004  }
2005 
2006  if (childFocus)
2007  childFocus->setFocus();
2008  d->appendChild(child);
2009  return child;
2010 }
double d
Definition: qnumeric_p.h:62
QWidget * focusWidget() const
Returns the last child of this widget that setFocus had been called on.
Definition: qwidget.cpp:6863
void setParent(QWidget *parent)
Sets the parent of the widget to parent, and resets the window flags.
Definition: qwidget.cpp:10479
QPointer< QWidget > widget
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
T * qobject_cast(QObject *object)
Definition: qobject.h:375
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
QWidget * viewport() const
Returns the viewport widget.
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59
Q_CORE_EXPORT void qWarning(const char *,...)
void setFocus()
Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its paren...
Definition: qwidget.h:432
void setWidget(QWidget *widget)
Sets widget as the internal widget of this subwindow.
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
Qt::WindowFlags windowFlags() const
Window flags are a combination of a type (e.
Definition: qwidget.h:939
The QMdiSubWindow class provides a subwindow class for QMdiArea.
Definition: qmdisubwindow.h:60

◆ background()

QBrush QMdiArea::background ( ) const

Referenced by removeSubWindow().

◆ cascadeSubWindows

void QMdiArea::cascadeSubWindows ( )
slot

Arranges all the child windows in a cascade pattern.

See also
tileSubWindows()

Definition at line 2521 of file qmdiarea.cpp.

2522 {
2523  Q_D(QMdiArea);
2524  if (!d->cascader)
2525  d->cascader = new SimpleCascader;
2526  d->rearrange(d->cascader);
2527 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59

◆ childEvent()

void QMdiArea::childEvent ( QChildEvent childEvent)
protectedvirtual

Reimplemented Function

Reimplemented from QObject.

Definition at line 2315 of file qmdiarea.cpp.

2316 {
2317  Q_D(QMdiArea);
2318  if (childEvent->type() == QEvent::ChildPolished) {
2319  if (QMdiSubWindow *mdiChild = qobject_cast<QMdiSubWindow *>(childEvent->child())) {
2320  if (d->childWindows.indexOf(mdiChild) == -1)
2321  d->appendChild(mdiChild);
2322  }
2323  }
2324 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
The QMdiSubWindow class provides a subwindow class for QMdiArea.
Definition: qmdisubwindow.h:60
QObject * child() const
Returns the child object that was added or removed.
Definition: qcoreevent.h:358

◆ closeActiveSubWindow

void QMdiArea::closeActiveSubWindow ( )
slot

Closes the active subwindow.

See also
closeAllSubWindows()

Definition at line 1870 of file qmdiarea.cpp.

1871 {
1872  Q_D(QMdiArea);
1873  if (d->active)
1874  d->active->close();
1875 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59

◆ closeAllSubWindows

void QMdiArea::closeAllSubWindows ( )
slot

Closes all subwindows by sending a QCloseEvent to each window.

You may receive subWindowActivated() 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 also
closeActiveSubWindow()

Definition at line 1904 of file qmdiarea.cpp.

1905 {
1906  Q_D(QMdiArea);
1907  if (d->childWindows.isEmpty())
1908  return;
1909 
1910  d->isSubWindowsTiled = false;
1911  foreach (QMdiSubWindow *child, d->childWindows) {
1912  if (!sanityCheck(child, "QMdiArea::closeAllSubWindows"))
1913  continue;
1914  child->close();
1915  }
1916 
1917  d->updateScrollBars();
1918 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
static bool sanityCheck(const QMdiSubWindow *const child, const char *where)
Definition: qmdiarea.cpp:198
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59
bool close()
Closes this widget.
Definition: qwidget.cpp:8305
The QMdiSubWindow class provides a subwindow class for QMdiArea.
Definition: qmdisubwindow.h:60

◆ currentSubWindow()

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 as activeSubWindow() if the QApplication containing QMdiArea is active.

See also
activeSubWindow(), QApplication::activeWindow()

Definition at line 1800 of file qmdiarea.cpp.

1801 {
1802  Q_D(const QMdiArea);
1803  if (d->childWindows.isEmpty())
1804  return 0;
1805 
1806  if (d->active)
1807  return d->active;
1808 
1809  if (d->isActivated && !window()->isMinimized())
1810  return 0;
1811 
1812  Q_ASSERT(d->indicesToActivatedChildren.count() > 0);
1813  int index = d->indicesToActivatedChildren.at(0);
1814  Q_ASSERT(index >= 0 && index < d->childWindows.size());
1815  QMdiSubWindow *current = d->childWindows.at(index);
1816  Q_ASSERT(current);
1817  return current;
1818 }
double d
Definition: qnumeric_p.h:62
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59
quint16 index
bool isMinimized() const
Definition: qwidget.cpp:3027
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
The QMdiSubWindow class provides a subwindow class for QMdiArea.
Definition: qmdisubwindow.h:60

◆ documentMode()

bool QMdiArea::documentMode ( ) const

Referenced by setViewMode().

◆ event()

bool QMdiArea::event ( QEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QAbstractScrollArea.

Definition at line 2532 of file qmdiarea.cpp.

Referenced by eventFilter(), and viewportEvent().

2533 {
2534  Q_D(QMdiArea);
2535  switch (event->type()) {
2536 #ifdef Q_WS_WIN
2537  // QWidgetPrivate::hide_helper activates another sub-window when closing a
2538  // modal dialog on Windows (see activateWindow() inside the the ifdef).
2540  d->activateCurrentWindow();
2541  break;
2542 #endif
2543  case QEvent::WindowActivate: {
2544  d->isActivated = true;
2545  if (d->childWindows.isEmpty())
2546  break;
2547  if (!d->active)
2548  d->activateCurrentWindow();
2549  d->setChildActivationEnabled(false, true);
2550  break;
2551  }
2553  d->isActivated = false;
2554  d->setChildActivationEnabled(false, true);
2555  break;
2556  case QEvent::StyleChange:
2557  // Re-tile the views if we're in tiled mode. Re-tile means we will change
2558  // the geometry of the children, which in turn means 'isSubWindowsTiled'
2559  // is set to false, so we have to update the state at the end.
2560  if (d->isSubWindowsTiled) {
2561  tileSubWindows();
2562  d->isSubWindowsTiled = true;
2563  }
2564  break;
2566  foreach (QMdiSubWindow *window, d->childWindows) {
2567  if (sanityCheck(window, "QMdiArea::WindowIconChange"))
2568  QApplication::sendEvent(window, event);
2569  }
2570  break;
2571  case QEvent::Hide:
2572  d->setActive(d->active, false, false);
2573  d->setChildActivationEnabled(false);
2574  break;
2575 #ifndef QT_NO_TABBAR
2577  d->updateTabBarGeometry();
2578  break;
2579 #endif
2580  default:
2581  break;
2582  }
2583  return QAbstractScrollArea::event(event);
2584 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
static bool sanityCheck(const QMdiSubWindow *const child, const char *where)
Definition: qmdiarea.cpp:198
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
bool event(QEvent *)
Reimplemented Function
void tileSubWindows()
Arranges all child windows in a tile pattern.
Definition: qmdiarea.cpp:2508
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
The QMdiSubWindow class provides a subwindow class for QMdiArea.
Definition: qmdisubwindow.h:60

◆ eventFilter()

bool QMdiArea::eventFilter ( QObject object,
QEvent event 
)
protectedvirtual

Reimplemented Function

Reimplemented from QObject.

Definition at line 2589 of file qmdiarea.cpp.

2590 {
2591  if (!object)
2592  return QAbstractScrollArea::eventFilter(object, event);
2593 
2594  Q_D(QMdiArea);
2595  // Global key events with Ctrl modifier.
2596  if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) {
2597 
2598  QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
2599  // Ingore key events without a Ctrl modifier (except for press/release on the modifier itself).
2600 #ifdef Q_WS_MAC
2601  if (!(keyEvent->modifiers() & Qt::MetaModifier) && keyEvent->key() != Qt::Key_Meta)
2602 #else
2603  if (!(keyEvent->modifiers() & Qt::ControlModifier) && keyEvent->key() != Qt::Key_Control)
2604 #endif
2605  return QAbstractScrollArea::eventFilter(object, event);
2606 
2607  // Find closest mdi area (in case we have a nested workspace).
2608  QMdiArea *area = mdiAreaParent(static_cast<QWidget *>(object));
2609  if (!area)
2610  return QAbstractScrollArea::eventFilter(object, event);
2611 
2612  const bool keyPress = (event->type() == QEvent::KeyPress) ? true : false;
2613 
2614  // 1) Ctrl-Tab once -> activate the previously active window.
2615  // 2) Ctrl-Tab (Tab, Tab, ...) -> iterate through all windows (activateNextSubWindow()).
2616  // 3) Ctrl-Shift-Tab (Tab, Tab, ...) -> iterate through all windows in the opposite
2617  // direction (activatePreviousSubWindow())
2618  switch (keyEvent->key()) {
2619 #ifdef Q_WS_MAC
2620  case Qt::Key_Meta:
2621 #else
2622  case Qt::Key_Control:
2623 #endif
2624  if (keyPress)
2625  area->d_func()->startTabToPreviousTimer();
2626  else
2627  area->d_func()->activateHighlightedWindow();
2628  break;
2629  case Qt::Key_Tab:
2630  case Qt::Key_Backtab:
2631  if (keyPress)
2632  area->d_func()->highlightNextSubWindow(keyEvent->key() == Qt::Key_Tab ? 1 : -1);
2633  return true;
2634 #ifndef QT_NO_RUBBERBAND
2635  case Qt::Key_Escape:
2636  area->d_func()->hideRubberBand();
2637  break;
2638 #endif
2639  default:
2640  break;
2641  }
2642  return QAbstractScrollArea::eventFilter(object, event);
2643  }
2644 
2645  QMdiSubWindow *subWindow = qobject_cast<QMdiSubWindow *>(object);
2646 
2647  if (!subWindow) {
2648  // QApplication events:
2649  if (event->type() == QEvent::ApplicationActivate && !d->active
2650  && isVisible() && !window()->isMinimized()) {
2651  d->activateCurrentWindow();
2652  } else if (event->type() == QEvent::ApplicationDeactivate && d->active) {
2653  d->setActive(d->active, false, false);
2654  }
2655  return QAbstractScrollArea::eventFilter(object, event);
2656  }
2657 
2658  // QMdiSubWindow events:
2659  switch (event->type()) {
2660  case QEvent::Move:
2661  case QEvent::Resize:
2662  if (d->tileCalledFromResizeEvent)
2663  break;
2664  d->updateScrollBars();
2665  if (!subWindow->isMinimized())
2666  d->isSubWindowsTiled = false;
2667  break;
2668  case QEvent::Show:
2669 #ifndef QT_NO_TABBAR
2670  if (d->tabBar) {
2671  const int tabIndex = d->childWindows.indexOf(subWindow);
2672  if (!d->tabBar->isTabEnabled(tabIndex))
2673  d->tabBar->setTabEnabled(tabIndex, true);
2674  }
2675 #endif // QT_NO_TABBAR
2676  // fall through
2677  case QEvent::Hide:
2678  d->isSubWindowsTiled = false;
2679  break;
2680 #ifndef QT_NO_RUBBERBAND
2681  case QEvent::Close:
2682  if (d->childWindows.indexOf(subWindow) == d->indexToHighlighted)
2683  d->hideRubberBand();
2684  break;
2685 #endif
2686 #ifndef QT_NO_TABBAR
2689  if (d->tabBar)
2690  d->tabBar->setTabText(d->childWindows.indexOf(subWindow), tabTextFor(subWindow));
2691  break;
2693  if (d->tabBar)
2694  d->tabBar->setTabIcon(d->childWindows.indexOf(subWindow), subWindow->windowIcon());
2695  break;
2696 #endif // QT_NO_TABBAR
2697  default:
2698  break;
2699  }
2700  return QAbstractScrollArea::eventFilter(object, event);
2701 }
double d
Definition: qnumeric_p.h:62
The QKeyEvent class describes a key event.
Definition: qevent.h:224
static void keyEvent(KeyAction action, QWidget *widget, char ascii, Qt::KeyboardModifiers modifier=Qt::NoModifier, int delay=-1)
bool isVisible() const
Definition: qwidget.h:1005
static QMdiArea * mdiAreaParent(QWidget *widget)
Definition: qmdiarea.cpp:259
T * qobject_cast(QObject *object)
Definition: qobject.h:375
#define Q_D(Class)
Definition: qglobal.h:2482
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately after the event occurred.
Definition: qevent.cpp:999
int key() const
Returns the code of the key that was pressed or released.
Definition: qevent.h:231
QIcon windowIcon() const
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59
virtual bool eventFilter(QObject *, QEvent *)
Filters events if this object has been installed as an event filter for the watched object...
Definition: qobject.cpp:1375
static void keyPress(QWidget *widget, char key, Qt::KeyboardModifiers modifier=Qt::NoModifier, int delay=-1)
bool event(QEvent *event)
Reimplemented Function
Definition: qmdiarea.cpp:2532
if(void) toggleToolbarShown
bool isMinimized() const
Definition: qwidget.cpp:3027
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
static QString tabTextFor(QMdiSubWindow *subWindow)
Definition: qmdiarea.cpp:289
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
The QMdiSubWindow class provides a subwindow class for QMdiArea.
Definition: qmdisubwindow.h:60
#define QT_NO_TABBAR
static int area(const QSize &s)
Definition: qicon.cpp:155

◆ minimumSizeHint()

QSize QMdiArea::minimumSizeHint ( ) const
virtual

Reimplemented Function

Reimplemented from QAbstractScrollArea.

Definition at line 1775 of file qmdiarea.cpp.

1776 {
1777  Q_D(const QMdiArea);
1778  QSize size(style()->pixelMetric(QStyle::PM_MdiSubWindowMinimizedWidth, 0, this),
1779  style()->pixelMetric(QStyle::PM_TitleBarHeight, 0, this));
1781  if (!d->scrollBarsEnabled()) {
1782  foreach (QMdiSubWindow *child, d->childWindows) {
1783  if (!sanityCheck(child, "QMdiArea::sizeHint"))
1784  continue;
1785  size = size.expandedTo(child->minimumSizeHint());
1786  }
1787  }
1789 }
double d
Definition: qnumeric_p.h:62
QSize size() const
static QSize globalStrut()
QSize expandedTo(const QSize &) const
Returns a size holding the maximum width and height of this size and the given otherSize.
Definition: qsize.h:187
#define Q_D(Class)
Definition: qglobal.h:2482
QStyle * style() const
Definition: qwidget.cpp:2742
static bool sanityCheck(const QMdiSubWindow *const child, const char *where)
Definition: qmdiarea.cpp:198
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59
QSize minimumSizeHint() const
Reimplemented Function
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QSize minimumSizeHint() const
Reimplemented Function
The QMdiSubWindow class provides a subwindow class for QMdiArea.
Definition: qmdisubwindow.h:60

◆ paintEvent()

void QMdiArea::paintEvent ( QPaintEvent paintEvent)
protectedvirtual

Reimplemented Function

Reimplemented from QAbstractScrollArea.

Definition at line 2706 of file qmdiarea.cpp.

2707 {
2708  Q_D(QMdiArea);
2709  QPainter painter(d->viewport);
2710  const QVector<QRect> &exposedRects = paintEvent->region().rects();
2711  for (int i = 0; i < exposedRects.size(); ++i)
2712  painter.fillRect(exposedRects.at(i), d->background);
2713 }
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59
const QRegion & region() const
Returns the region that needs to be updated.
Definition: qevent.h:306
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QVector< QRect > rects() const
Returns an array of non-overlapping rectangles that make up the region.
Definition: qregion.cpp:4412
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

◆ removeSubWindow()

void QMdiArea::removeSubWindow ( QWidget widget)

Removes widget from the MDI area.

The widget must be either a QMdiSubWindow or a widget that is the internal widget of a subwindow. Note widget is never actually deleted by QMdiArea. If a QMdiSubWindow 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 the QMdiSubWindow is not removed.

See also
addSubWindow()

Definition at line 2022 of file qmdiarea.cpp.

2023 {
2024  if (!widget) {
2025  qWarning("QMdiArea::removeSubWindow: null pointer to widget");
2026  return;
2027  }
2028 
2029  Q_D(QMdiArea);
2030  if (d->childWindows.isEmpty())
2031  return;
2032 
2033  if (QMdiSubWindow *child = qobject_cast<QMdiSubWindow *>(widget)) {
2034  int index = d->childWindows.indexOf(child);
2035  if (index == -1) {
2036  qWarning("QMdiArea::removeSubWindow: window is not inside workspace");
2037  return;
2038  }
2039  d->disconnectSubWindow(child);
2040  d->childWindows.removeAll(child);
2041  d->indicesToActivatedChildren.removeAll(index);
2042  d->updateActiveWindow(index, d->active == child);
2043  child->setParent(0);
2044  return;
2045  }
2046 
2047  bool found = false;
2048  foreach (QMdiSubWindow *child, d->childWindows) {
2049  if (!sanityCheck(child, "QMdiArea::removeSubWindow"))
2050  continue;
2051  if (child->widget() == widget) {
2052  child->setWidget(0);
2053  Q_ASSERT(!child->widget());
2054  found = true;
2055  break;
2056  }
2057  }
2058 
2059  if (!found)
2060  qWarning("QMdiArea::removeSubWindow: widget is not child of any window inside QMdiArea");
2061 }
double d
Definition: qnumeric_p.h:62
QPointer< QWidget > widget
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
static bool sanityCheck(const QMdiSubWindow *const child, const char *where)
Definition: qmdiarea.cpp:198
QWidget * widget() const
Returns the current internal widget.
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59
Q_CORE_EXPORT void qWarning(const char *,...)
void setWidget(QWidget *widget)
Sets widget as the internal widget of this subwindow.
quint16 index
The QMdiSubWindow class provides a subwindow class for QMdiArea.
Definition: qmdisubwindow.h:60

◆ resizeEvent()

void QMdiArea::resizeEvent ( QResizeEvent resizeEvent)
protectedvirtual

Reimplemented Function

Reimplemented from QAbstractScrollArea.

Definition at line 2329 of file qmdiarea.cpp.

2330 {
2331  Q_D(QMdiArea);
2332  if (d->childWindows.isEmpty()) {
2333  resizeEvent->ignore();
2334  return;
2335  }
2336 
2337 #ifndef QT_NO_TABBAR
2338  d->updateTabBarGeometry();
2339 #endif
2340 
2341  // Re-tile the views if we're in tiled mode. Re-tile means we will change
2342  // the geometry of the children, which in turn means 'isSubWindowsTiled'
2343  // is set to false, so we have to update the state at the end.
2344  if (d->isSubWindowsTiled) {
2345  d->tileCalledFromResizeEvent = true;
2346  tileSubWindows();
2347  d->tileCalledFromResizeEvent = false;
2348  d->isSubWindowsTiled = true;
2349  d->startResizeTimer();
2350  // We don't have scroll bars or any maximized views.
2351  return;
2352  }
2353 
2354  // Resize maximized views.
2355  bool hasMaximizedSubWindow = false;
2356  foreach (QMdiSubWindow *child, d->childWindows) {
2357  if (sanityCheck(child, "QMdiArea::resizeEvent") && child->isMaximized()
2358  && child->size() != resizeEvent->size()) {
2359  child->resize(resizeEvent->size());
2360  if (!hasMaximizedSubWindow)
2361  hasMaximizedSubWindow = true;
2362  }
2363  }
2364 
2365  d->updateScrollBars();
2366 
2367  // Minimized views are stacked under maximized views so there's
2368  // no need to re-arrange minimized views on-demand. Start a timer
2369  // just to make things faster with subsequent resize events.
2370  if (hasMaximizedSubWindow)
2371  d->startResizeTimer();
2372  else
2373  d->arrangeMinimizedSubWindows();
2374 }
double d
Definition: qnumeric_p.h:62
QSize size() const
#define Q_D(Class)
Definition: qglobal.h:2482
static bool sanityCheck(const QMdiSubWindow *const child, const char *where)
Definition: qmdiarea.cpp:198
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59
bool isMaximized() const
Definition: qwidget.cpp:3074
void resize(int w, int h)
This corresponds to resize(QSize(w, h)).
Definition: qwidget.h:1014
const QSize & size() const
Returns the new size of the widget.
Definition: qevent.h:355
void tileSubWindows()
Arranges all child windows in a tile pattern.
Definition: qmdiarea.cpp:2508
void ignore()
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
Definition: qcoreevent.h:310
The QMdiSubWindow class provides a subwindow class for QMdiArea.
Definition: qmdisubwindow.h:60

◆ scrollContentsBy()

void QMdiArea::scrollContentsBy ( int  dx,
int  dy 
)
protectedvirtual

Reimplemented Function

Reimplemented from QAbstractScrollArea.

Definition at line 2491 of file qmdiarea.cpp.

2492 {
2493  Q_D(QMdiArea);
2494  const bool wasSubWindowsTiled = d->isSubWindowsTiled;
2495  d->ignoreGeometryChange = true;
2496  viewport()->scroll(isLeftToRight() ? dx : -dx, dy);
2497  d->arrangeMinimizedSubWindows();
2498  d->ignoreGeometryChange = false;
2499  if (wasSubWindowsTiled)
2500  d->isSubWindowsTiled = true;
2501 }
void scroll(int dx, int dy)
Scrolls the widget including its children dx pixels to the right and dy downward. ...
Definition: qwidget.cpp:10684
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QWidget * viewport() const
Returns the viewport widget.
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59
bool isLeftToRight() const
Definition: qwidget.h:429

◆ setActivationOrder()

void QMdiArea::setActivationOrder ( WindowOrder  order)

Definition at line 2110 of file qmdiarea.cpp.

2111 {
2112  Q_D(QMdiArea);
2113  if (order != d->activationOrder)
2114  d->activationOrder = order;
2115 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59

◆ setActiveSubWindow

void QMdiArea::setActiveSubWindow ( QMdiSubWindow window)
slot

Activates the subwindow window.

If window is 0, any current active window is deactivated.

See also
activeSubWindow()

Definition at line 1844 of file qmdiarea.cpp.

1845 {
1846  Q_D(QMdiArea);
1847  if (!window) {
1848  d->activateWindow(0);
1849  return;
1850  }
1851 
1852  if (d->childWindows.isEmpty()) {
1853  qWarning("QMdiArea::setActiveSubWindow: workspace is empty");
1854  return;
1855  }
1856 
1857  if (d->childWindows.indexOf(window) == -1) {
1858  qWarning("QMdiArea::setActiveSubWindow: window is not inside workspace");
1859  return;
1860  }
1861 
1862  d->activateWindow(window);
1863 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59
Q_CORE_EXPORT void qWarning(const char *,...)

◆ setBackground()

void QMdiArea::setBackground ( const QBrush background)

Definition at line 2079 of file qmdiarea.cpp.

Referenced by QMdiArea().

2080 {
2081  Q_D(QMdiArea);
2082  if (d->background != brush) {
2083  d->background = brush;
2084  d->viewport->setAttribute(Qt::WA_OpaquePaintEvent, brush.isOpaque());
2085  update();
2086  }
2087 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59

◆ setDocumentMode()

void QMdiArea::setDocumentMode ( bool  enabled)

Definition at line 2185 of file qmdiarea.cpp.

2186 {
2187  Q_D(QMdiArea);
2188  if (d->documentMode == enabled)
2189  return;
2190 
2191  d->documentMode = enabled;
2192  d->refreshTabBar();
2193 }
double d
Definition: qnumeric_p.h:62
bool enabled
whether the widget is enabled
Definition: qwidget.h:157
#define Q_D(Class)
Definition: qglobal.h:2482
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59

◆ setOption()

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

If on is true, option is enabled on the MDI area; otherwise it is disabled.

See AreaOption for the effect of each option.

See also
AreaOption, testOption()

Definition at line 2123 of file qmdiarea.cpp.

2124 {
2125  Q_D(QMdiArea);
2126  if (on && !(d->options & option))
2127  d->options |= option;
2128  else if (!on && (d->options & option))
2129  d->options &= ~option;
2130 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59

◆ setTabPosition()

void QMdiArea::setTabPosition ( QTabWidget::TabPosition  position)

Definition at line 2301 of file qmdiarea.cpp.

2302 {
2303  Q_D(QMdiArea);
2304  if (d->tabPosition == position)
2305  return;
2306 
2307  d->tabPosition = position;
2308  d->refreshTabBar();
2309 }
double d
Definition: qnumeric_p.h:62
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
#define Q_D(Class)
Definition: qglobal.h:2482
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59

◆ setTabsClosable()

void QMdiArea::setTabsClosable ( bool  closable)

Definition at line 2213 of file qmdiarea.cpp.

2214 {
2215  Q_D(QMdiArea);
2216  if (d->tabsClosable == closable)
2217  return;
2218 
2219  d->tabsClosable = closable;
2220  d->refreshTabBar();
2221 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59

◆ setTabShape()

void QMdiArea::setTabShape ( QTabWidget::TabShape  shape)

Definition at line 2272 of file qmdiarea.cpp.

2273 {
2274  Q_D(QMdiArea);
2275  if (d->tabShape == shape)
2276  return;
2277 
2278  d->tabShape = shape;
2279  d->refreshTabBar();
2280 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59

◆ setTabsMovable()

void QMdiArea::setTabsMovable ( bool  movable)

Definition at line 2241 of file qmdiarea.cpp.

2242 {
2243  Q_D(QMdiArea);
2244  if (d->tabsMovable == movable)
2245  return;
2246 
2247  d->tabsMovable = movable;
2248  d->refreshTabBar();
2249 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59

◆ setupViewport

void QMdiArea::setupViewport ( QWidget viewport)
protectedslot

This slot is called by QAbstractScrollArea after setViewport() has been called.

Reimplement this function in a subclass of QMdiArea to initialize the new viewport before it is used.

See also
setViewport()

Definition at line 2722 of file qmdiarea.cpp.

2723 {
2724  Q_D(QMdiArea);
2725  if (viewport)
2726  viewport->setAttribute(Qt::WA_OpaquePaintEvent, d->background.isOpaque());
2727  foreach (QMdiSubWindow *child, d->childWindows) {
2728  if (!sanityCheck(child, "QMdiArea::setupViewport"))
2729  continue;
2730  child->setParent(viewport, child->windowFlags());
2731  }
2732 }
double d
Definition: qnumeric_p.h:62
void setParent(QWidget *parent)
Sets the parent of the widget to parent, and resets the window flags.
Definition: qwidget.cpp:10479
#define Q_D(Class)
Definition: qglobal.h:2482
static bool sanityCheck(const QMdiSubWindow *const child, const char *where)
Definition: qmdiarea.cpp:198
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
Qt::WindowFlags windowFlags() const
Window flags are a combination of a type (e.
Definition: qwidget.h:939
The QMdiSubWindow class provides a subwindow class for QMdiArea.
Definition: qmdisubwindow.h:60

◆ setViewMode()

void QMdiArea::setViewMode ( ViewMode  mode)

Definition at line 2160 of file qmdiarea.cpp.

2161 {
2162  Q_D(QMdiArea);
2163  d->setViewMode(mode);
2164 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59

◆ showEvent()

void QMdiArea::showEvent ( QShowEvent showEvent)
protectedvirtual

Reimplemented Function

Reimplemented from QWidget.

Definition at line 2403 of file qmdiarea.cpp.

2404 {
2405  Q_D(QMdiArea);
2406  if (!d->pendingRearrangements.isEmpty()) {
2407  bool skipPlacement = false;
2408  foreach (Rearranger *rearranger, d->pendingRearrangements) {
2409  // If this is the case, we don't have to lay out pending child windows
2410  // since the rearranger will find a placement for them.
2411  if (rearranger->type() != Rearranger::IconTiler && !skipPlacement)
2412  skipPlacement = true;
2413  d->rearrange(rearranger);
2414  }
2415  d->pendingRearrangements.clear();
2416 
2417  if (skipPlacement && !d->pendingPlacements.isEmpty())
2418  d->pendingPlacements.clear();
2419  }
2420 
2421  if (!d->pendingPlacements.isEmpty()) {
2422  foreach (QMdiSubWindow *window, d->pendingPlacements) {
2423  if (!window)
2424  continue;
2425  if (!window->testAttribute(Qt::WA_Resized)) {
2426  QSize newSize(window->sizeHint().boundedTo(viewport()->size()));
2427  window->resize(newSize.expandedTo(qSmartMinSize(window)));
2428  }
2429  if (!window->testAttribute(Qt::WA_Moved) && !window->isMinimized()
2430  && !window->isMaximized()) {
2431  d->place(d->placer, window);
2432  }
2433  }
2434  d->pendingPlacements.clear();
2435  }
2436 
2437  d->setChildActivationEnabled(true);
2438  d->activateCurrentWindow();
2439 
2440  QAbstractScrollArea::showEvent(showEvent);
2441 }
double d
Definition: qnumeric_p.h:62
virtual void showEvent(QShowEvent *)
This event handler can be reimplemented in a subclass to receive widget show events which are passed ...
Definition: qwidget.cpp:9842
Q_GUI_EXPORT QSize qSmartMinSize(const QSize &sizeHint, const QSize &minSizeHint, const QSize &minSize, const QSize &maxSize, const QSizePolicy &sizePolicy)
QSize size() const
QSize sizeHint() const
Reimplemented Function
#define Q_D(Class)
Definition: qglobal.h:2482
QSize boundedTo(const QSize &) const
Returns a size holding the minimum width and height of this size and the given otherSize.
Definition: qsize.h:192
QWidget * viewport() const
Returns the viewport widget.
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59
virtual Type type() const =0
bool isMaximized() const
Definition: qwidget.cpp:3074
void resize(int w, int h)
This corresponds to resize(QSize(w, h)).
Definition: qwidget.h:1014
bool isMinimized() const
Definition: qwidget.cpp:3027
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
The QMdiSubWindow class provides a subwindow class for QMdiArea.
Definition: qmdisubwindow.h:60

◆ sizeHint()

QSize QMdiArea::sizeHint ( ) const
virtual

Reimplemented Function

Reimplemented from QAbstractScrollArea.

Definition at line 1749 of file qmdiarea.cpp.

1750 {
1751  // Calculate a proper scale factor for QDesktopWidget::size().
1752  // This also takes into account that we can have nested workspaces.
1753  int nestedCount = 0;
1754  QWidget *widget = this->parentWidget();
1755  while (widget) {
1756  if (qobject_cast<QMdiArea *>(widget))
1757  ++nestedCount;
1758  widget = widget->parentWidget();
1759  }
1760  const int scaleFactor = 3 * (nestedCount + 1);
1761 
1762  QSize desktopSize = QApplication::desktop()->size();
1763  QSize size(desktopSize.width() * 2 / scaleFactor, desktopSize.height() * 2 / scaleFactor);
1764  foreach (QMdiSubWindow *child, d_func()->childWindows) {
1765  if (!sanityCheck(child, "QMdiArea::sizeHint"))
1766  continue;
1767  size = size.expandedTo(child->sizeHint());
1768  }
1770 }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
QSize size() const
QPointer< QWidget > widget
static QSize globalStrut()
QSize sizeHint() const
Reimplemented Function
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QSize expandedTo(const QSize &) const
Returns a size holding the maximum width and height of this size and the given otherSize.
Definition: qsize.h:187
int width() const
Returns the width.
Definition: qsize.h:126
static bool sanityCheck(const QMdiSubWindow *const child, const char *where)
Definition: qmdiarea.cpp:198
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
int height() const
Returns the height.
Definition: qsize.h:129
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
The QMdiSubWindow class provides a subwindow class for QMdiArea.
Definition: qmdisubwindow.h:60

◆ subWindowActivated

QMdiArea::subWindowActivated ( QMdiSubWindow window)
signal

QMdiArea emits this signal after window has been activated.

When window is 0, QMdiArea has just deactivated its last active window, and there are no active windows on the workspace.

See also
QMdiArea::activeSubWindow()

◆ subWindowList()

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

Returns a list of all subwindows in the MDI area.

If order is CreationOrder (the default), the windows are sorted in the order in which they were inserted into the workspace. If order is StackingOrder, the windows are listed in their stacking order, with the topmost window as the last item in the list. If order is ActivationHistoryOrder, the windows are listed according to their recent activation history.

See also
WindowOrder

Definition at line 1888 of file qmdiarea.cpp.

Referenced by QAccessibleMdiArea::childCount(), QAccessibleMdiArea::indexOfChild(), mdiAreaNavigate(), QAccessibleMdiArea::navigate(), QAccessibleMdiSubWindow::navigate(), QAccessibleMdiArea::state(), and QMdiAreaTabBar::subWindowFromIndex().

1889 {
1890  Q_D(const QMdiArea);
1891  return d->subWindowList(order, false);
1892 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59

◆ tabPosition()

QTabWidget::TabPosition QMdiArea::tabPosition ( ) const

Referenced by setTabShape().

◆ tabsClosable()

bool QMdiArea::tabsClosable ( ) const

Referenced by setDocumentMode().

◆ tabShape()

QTabWidget::TabShape QMdiArea::tabShape ( ) const

Referenced by setTabsMovable().

◆ tabsMovable()

bool QMdiArea::tabsMovable ( ) const

Referenced by setTabsClosable().

◆ testOption()

bool QMdiArea::testOption ( AreaOption  option) const

Returns true if option is enabled; otherwise returns false.

See also
AreaOption, setOption()

Definition at line 2137 of file qmdiarea.cpp.

Referenced by viewportEvent().

2138 {
2139  return d_func()->options & option;
2140 }

◆ tileSubWindows

void QMdiArea::tileSubWindows ( )
slot

Arranges all child windows in a tile pattern.

See also
cascadeSubWindows()

Definition at line 2508 of file qmdiarea.cpp.

Referenced by event(), and resizeEvent().

2509 {
2510  Q_D(QMdiArea);
2511  if (!d->regularTiler)
2512  d->regularTiler = new RegularTiler;
2513  d->rearrange(d->regularTiler);
2514 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59

◆ timerEvent()

void QMdiArea::timerEvent ( QTimerEvent timerEvent)
protectedvirtual

Reimplemented Function

Reimplemented from QObject.

Definition at line 2379 of file qmdiarea.cpp.

2380 {
2381  Q_D(QMdiArea);
2382  if (timerEvent->timerId() == d->resizeTimerId) {
2383  killTimer(d->resizeTimerId);
2384  d->resizeTimerId = -1;
2385  d->arrangeMinimizedSubWindows();
2386  } else if (timerEvent->timerId() == d->tabToPreviousTimerId) {
2387  killTimer(d->tabToPreviousTimerId);
2388  d->tabToPreviousTimerId = -1;
2389  if (d->indexToHighlighted < 0)
2390  return;
2391 #ifndef QT_NO_RUBBERBAND
2392  // We're not doing a "quick switch" ... show rubber band.
2393  Q_ASSERT(d->indexToHighlighted < d->childWindows.size());
2394  Q_ASSERT(d->rubberBand);
2395  d->showRubberBandFor(d->childWindows.at(d->indexToHighlighted));
2396 #endif
2397  }
2398 }
double d
Definition: qnumeric_p.h:62
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59
int timerId() const
Returns the unique timer identifier, which is the same identifier as returned from QObject::startTime...
Definition: qcoreevent.h:346
void killTimer(int id)
Kills the timer with timer identifier, id.
Definition: qobject.cpp:1650

◆ viewMode()

ViewMode QMdiArea::viewMode ( ) const

Referenced by testOption().

◆ viewportEvent()

bool QMdiArea::viewportEvent ( QEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QAbstractScrollArea.

Definition at line 2446 of file qmdiarea.cpp.

2447 {
2448  Q_D(QMdiArea);
2449  switch (event->type()) {
2450  case QEvent::ChildRemoved: {
2451  d->isSubWindowsTiled = false;
2452  QObject *removedChild = static_cast<QChildEvent *>(event)->child();
2453  for (int i = 0; i < d->childWindows.size(); ++i) {
2454  QObject *child = d->childWindows.at(i);
2455  if (!child || child == removedChild || !child->parent()
2456  || child->parent() != viewport()) {
2458  // In this case we can only rely on the child being a QObject
2459  // (or 0), but let's try and see if we can get more information.
2460  QWidget *mdiChild = qobject_cast<QWidget *>(removedChild);
2461  if (mdiChild && mdiChild->isMaximized())
2462  d->showActiveWindowMaximized = true;
2463  }
2464  d->disconnectSubWindow(child);
2465  const bool activeRemoved = i == d->indicesToActivatedChildren.at(0);
2466  d->childWindows.removeAt(i);
2467  d->indicesToActivatedChildren.removeAll(i);
2468  d->updateActiveWindow(i, activeRemoved);
2469  d->arrangeMinimizedSubWindows();
2470  break;
2471  }
2472  }
2473  d->updateScrollBars();
2474  break;
2475  }
2476  case QEvent::Destroy:
2477  d->isSubWindowsTiled = false;
2478  d->resetActiveWindow();
2479  d->childWindows.clear();
2480  qWarning("QMdiArea: Deleting the view port is undefined, use setViewport instead.");
2481  break;
2482  default:
2483  break;
2484  }
2485  return QAbstractScrollArea::viewportEvent(event);
2486 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
T * qobject_cast(QObject *object)
Definition: qobject.h:375
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_D(Class)
Definition: qglobal.h:2482
QWidget * viewport() const
Returns the viewport widget.
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59
Q_CORE_EXPORT void qWarning(const char *,...)
bool isMaximized() const
Definition: qwidget.cpp:3074
The QChildEvent class contains event parameters for child object events.
Definition: qcoreevent.h:353
virtual bool viewportEvent(QEvent *)
The main event handler for the scrolling area (the viewport() widget).
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
bool event(QEvent *event)
Reimplemented Function
Definition: qmdiarea.cpp:2532
bool testOption(AreaOption opton) const
Returns true if option is enabled; otherwise returns false.
Definition: qmdiarea.cpp:2137
Type type() const
Returns the event type.
Definition: qcoreevent.h:303

Properties

◆ activationOrder

QMdiArea::WindowOrder QMdiArea::activationOrder
private

the ordering criteria for subwindow lists

Since
4.4

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

See also
subWindowList()

Definition at line 64 of file qmdiarea.h.

◆ background

QBrush QMdiArea::background
private

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).

Definition at line 63 of file qmdiarea.h.

◆ documentMode

bool QMdiArea::documentMode
private

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

Since
4.5

Document mode is disabled by default.

See also
QTabBar::documentMode, setViewMode()

Definition at line 67 of file qmdiarea.h.

◆ tabPosition

QTabWidget::TabPosition QMdiArea::tabPosition
private

the position of the tabs in tabbed view mode.

Since
4.4

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

See also
QTabWidget::TabPosition, setViewMode()

Definition at line 73 of file qmdiarea.h.

◆ tabsClosable

bool QMdiArea::tabsClosable
private

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

Since
4.8

Tabs are not closable by default.

See also
QTabBar::tabsClosable, setViewMode()

Definition at line 68 of file qmdiarea.h.

◆ tabShape

QTabWidget::TabShape QMdiArea::tabShape
private

the shape of the tabs in tabbed view mode.

Since
4.4

Possible values for this property are QTabWidget::Rounded (default) or QTabWidget::Triangular.

See also
QTabWidget::TabShape, setViewMode()

Definition at line 72 of file qmdiarea.h.

◆ tabsMovable

bool QMdiArea::tabsMovable
private

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

Since
4.8

Tabs are not movable by default.

See also
QTabBar::movable, setViewMode()

Definition at line 69 of file qmdiarea.h.

◆ viewMode

QMdiArea::ViewMode QMdiArea::viewMode
private

the way sub-windows are displayed in the QMdiArea.

Since
4.4

By default, the SubWindowView is used to display sub-windows.

See also
ViewMode, setTabShape(), setTabPosition()

Definition at line 65 of file qmdiarea.h.


The documentation for this class was generated from the following files: