Qt Jambi Home

com.trolltech.qt.gui
Class QWorkspace

java.lang.Object
  extended by com.trolltech.qt.QSignalEmitter
      extended by com.trolltech.qt.QtJambiObject
          extended by com.trolltech.qt.core.QObject
              extended by com.trolltech.qt.gui.QWidget
                  extended by com.trolltech.qt.gui.QWorkspace
All Implemented Interfaces:
QPaintDeviceInterface, QtJambiInterface

public class QWorkspace
extends QWidget

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

The QWorkspace widget provides a workspace window that can be used in an MDI application.

This class is deprecated. Use QMdiArea instead.

Multiple Document Interface (MDI) applications are typically composed of a main window containing a menu bar, a toolbar, and a central QWorkspace widget. The workspace itself is used to display a number of child windows, each of which is a widget.

The workspace itself is an ordinary Qt widget. It has a standard constructor that takes a parent widget. Workspaces can be placed in any layout, but are typically given as the central widget in a QMainWindow:

    MainWindow::MainWindow()
    {
        workspace = new QWorkspace;
        setCentralWidget(workspace);
        ...
    }

Child windows (MDI windows) are standard Qt widgets that are inserted into the workspace with addWindow. As with top-level widgets, you can call functions such as show, hide, showMaximized, and setWindowTitle on a child window to change its appearance within the workspace. You can also provide widget flags to determine the layout of the decoration or the behavior of the widget itself.

To change or retrieve the geometry of a child window, you must operate on its parentWidget. The parentWidget provides access to the decorated frame that contains the child window widget. When a child window is maximised, its decorated frame is hidden. If the top-level widget contains a menu bar, it will display the maximised window's operations menu to the left of the menu entries, and the window's controls to the right.

A child window becomes active when it gets the keyboard focus, or when setFocus is called. The user can activate a window by moving focus in the usual ways, for example by clicking a window or by pressing Tab. The workspace emits a signal windowActivated when the active window changes, and the function activeWindow returns a pointer to the active child window, or 0 if no window is active.

The convenience function windowList returns a list of all child windows. This information could be used in a popup menu containing a list of windows, for example. This feature is also available as part of the Window Menu Solution.

QWorkspace provides two built-in layout strategies for child windows: cascade and tile. Both are slots so you can easily connect menu entries to them.

If you want your users to be able to work with child windows larger than the visible workspace area, set the scrollBarsEnabled property to true.

See Also:
QDockWidget, Example

Nested Class Summary
static class QWorkspace.WindowOrder
          Specifies the order in which child windows are returned from windowList.
 
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QWidget
QWidget.RenderFlag, QWidget.RenderFlags
 
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I>
 
Field Summary
 QSignalEmitter.Signal1<QWidget> windowActivated
          This signal is emitted when the child window w becomes active.
 
Fields inherited from class com.trolltech.qt.gui.QWidget
customContextMenuRequested
 
Constructor Summary
QWorkspace()
          Equivalent to QWorkspace(0).
QWorkspace(QWidget parent)
          Constructs a workspace with the given parent.
 
Method Summary
 void activateNextWindow()
          Gives the input focus to the next window in the list of child windows.
 void activatePreviousWindow()
          Gives the input focus to the previous window in the list of child windows.
 QWidget activeWindow()
          Returns a pointer to the widget corresponding to the active child window, or 0 if no window is active.
 QWidget addWindow(QWidget w)
          Equivalent to addWindow(w, 0).
 QWidget addWindow(QWidget w, Qt.WindowFlags flags)
          Adds widget w as new sub window to the workspace.
 QWidget addWindow(QWidget w, Qt.WindowType... flags)
          Adds widget w as new sub window to the workspace.
 void arrangeIcons()
          Arranges all iconified windows at the bottom of the workspace.
 QBrush background()
          Returns the workspace's background.
 void cascade()
          Arranges all the child windows in a cascade pattern.
protected  void changeEvent(QEvent arg__1)
          

This event handler can be reimplemented to handle state changes.

protected  void childEvent(QChildEvent arg__1)
          

This event handler can be reimplemented in a subclass to receive child events.

 void closeActiveWindow()
          Closes the child window that is currently active.
 void closeAllWindows()
          Closes all child windows.
 boolean event(QEvent e)
          

This is the main event handler; it handles event arg__1.

 boolean eventFilter(QObject arg__1, QEvent arg__2)
          

Filters events if this object has been installed as an event filter for the arg__1 object.

static QWorkspace fromNativePointer(QNativePointer nativePointer)
          This function returns the QWorkspace instance pointed to by nativePointer
protected  void hideEvent(QHideEvent e)
          

This event handler can be reimplemented in a subclass to receive widget hide events.

protected  void paintEvent(QPaintEvent e)
          

This event handler can be reimplemented in a subclass to receive paint events which are passed in the arg__1 parameter.

protected  void resizeEvent(QResizeEvent arg__1)
          

This event handler can be reimplemented in a subclass to receive widget resize events which are passed in the arg__1 parameter.

 boolean scrollBarsEnabled()
          Returns whether the workspace provides scroll bars.
 void setActiveWindow(QWidget w)
          Makes the child window that contains w the active child window.
 void setBackground(QBrush background)
          Sets the workspace's background to background.
 void setScrollBarsEnabled(boolean enable)
          Sets whether the workspace provides scroll bars to enable.
protected  void showEvent(QShowEvent e)
          

This event handler can be reimplemented in a subclass to receive widget show events which are passed in the arg__1 parameter.

 QSize sizeHint()
          

Returns the recommended size for the widget.

 void tile()
          Arranges all child windows in a tile pattern.
protected  void wheelEvent(QWheelEvent e)
          

This event handler, for event arg__1, can be reimplemented in a subclass to receive wheel events for the widget.

 java.util.List<QWidget> windowList()
          Returns a list of all visible or minimized child windows.
 java.util.List<QWidget> windowList(QWorkspace.WindowOrder order)
          Returns a list of all visible or minimized child windows.
 
Methods inherited from class com.trolltech.qt.gui.QWidget
acceptDrops, accessibleDescription, accessibleName, actionEvent, actions, activateWindow, addAction, addActions, adjustSize, autoFillBackground, backgroundRole, baseSize, childAt, childAt, childrenRect, childrenRegion, clearFocus, clearMask, close, closeEvent, contentsRect, contextMenuEvent, contextMenuPolicy, createWinId, cursor, depth, destroy, destroy, destroy, devType, dragEnterEvent, dragLeaveEvent, dragMoveEvent, dropEvent, ensurePolished, enterEvent, focusInEvent, focusNextChild, focusNextPrevChild, focusOutEvent, focusPolicy, focusPreviousChild, focusProxy, focusWidget, font, fontInfo, fontMetrics, foregroundRole, frameGeometry, frameSize, geometry, getContentsMargins, grabKeyboard, grabMouse, grabMouse, grabShortcut, grabShortcut, hasFocus, hasMouseTracking, height, heightForWidth, heightMM, hide, inputContext, inputMethodEvent, inputMethodQuery, insertAction, insertActions, isActiveWindow, isAncestorOf, isEnabled, isEnabledTo, isFullScreen, isHidden, isLeftToRight, isMaximized, isMinimized, isModal, isRightToLeft, isVisible, isVisibleTo, isWindow, isWindowModified, keyboardGrabber, keyPressEvent, keyReleaseEvent, layout, layoutDirection, leaveEvent, locale, logicalDpiX, logicalDpiY, lower, mapFrom, mapFromGlobal, mapFromParent, mapTo, mapToGlobal, mapToParent, mask, maximumHeight, maximumSize, maximumWidth, metric, minimumHeight, minimumSize, minimumSizeHint, minimumWidth, mouseDoubleClickEvent, mouseGrabber, mouseMoveEvent, mousePressEvent, mouseReleaseEvent, move, move, moveEvent, nextInFocusChain, normalGeometry, numColors, overrideWindowFlags, overrideWindowFlags, overrideWindowState, overrideWindowState, paintEngine, paintingActive, palette, parentWidget, physicalDpiX, physicalDpiY, pos, raise, rect, releaseKeyboard, releaseMouse, releaseShortcut, removeAction, render, render, render, render, render, repaint, repaint, repaint, repaint, resetInputContext, resize, resize, restoreGeometry, saveGeometry, scroll, scroll, setAcceptDrops, setAccessibleDescription, setAccessibleName, setAttribute, setAttribute, setAutoFillBackground, setBackgroundRole, setBaseSize, setBaseSize, setContentsMargins, setContentsMargins, setContextMenuPolicy, setCursor, setDisabled, setEnabled, setFixedHeight, setFixedSize, setFixedSize, setFixedWidth, setFocus, setFocus, setFocusPolicy, setFocusProxy, setFont, setForegroundRole, setGeometry, setGeometry, setHidden, setInputContext, setLayout, setLayoutDirection, setLocale, setMask, setMask, setMaximumHeight, setMaximumSize, setMaximumSize, setMaximumWidth, setMinimumHeight, setMinimumSize, setMinimumSize, setMinimumWidth, setMouseTracking, setPalette, setParent, setParent, setParent, setShortcutAutoRepeat, setShortcutAutoRepeat, setShortcutEnabled, setShortcutEnabled, setSizeIncrement, setSizeIncrement, setSizePolicy, setSizePolicy, setStatusTip, setStyle, setStyleSheet, setTabOrder, setToolTip, setUpdatesEnabled, setVisible, setWhatsThis, setWindowFlags, setWindowFlags, setWindowIcon, setWindowIconText, setWindowModality, setWindowModified, setWindowOpacity, setWindowRole, setWindowState, setWindowState, setWindowTitle, show, showFullScreen, showMaximized, showMinimized, showNormal, size, sizeIncrement, sizePolicy, stackUnder, statusTip, style, styleSheet, tabletEvent, testAttribute, toolTip, underMouse, unsetCursor, unsetLayoutDirection, unsetLocale, update, update, update, update, updateGeometry, updateMicroFocus, updatesEnabled, visibleRegion, whatsThis, width, widthMM, window, windowFlags, windowIcon, windowIconText, windowModality, windowOpacity, windowRole, windowState, windowTitle, windowType, winId, x, y
 
Methods inherited from class com.trolltech.qt.core.QObject
blockSignals, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, property, removeEventFilter, setObjectName, setParent, setProperty, signalsBlocked, startTimer, thread, timerEvent
 
Methods inherited from class com.trolltech.qt.QtJambiObject
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr
 
Methods inherited from class com.trolltech.qt.QSignalEmitter
disconnect, disconnect, signalSender
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.trolltech.qt.QtJambiInterface
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership
 

Field Detail

windowActivated

public final QSignalEmitter.Signal1<QWidget> windowActivated

This signal is emitted when the child window w becomes active. Note that w can be 0, and that more than one signal may be emitted for a single activation event.

Compatible Slot Signatures:
void mySlot(com.trolltech.qt.gui.QWidget w)
void mySlot()
See Also:
activeWindow, windowList

Constructor Detail

QWorkspace

public QWorkspace()

Equivalent to QWorkspace(0).


QWorkspace

public QWorkspace(QWidget parent)

Constructs a workspace with the given parent.

Method Detail

activateNextWindow

public final void activateNextWindow()

Gives the input focus to the next window in the list of child windows.

See Also:
activatePreviousWindow

activatePreviousWindow

public final void activatePreviousWindow()

Gives the input focus to the previous window in the list of child windows.

See Also:
activateNextWindow

activeWindow

public final QWidget activeWindow()

Returns a pointer to the widget corresponding to the active child window, or 0 if no window is active.

See Also:
setActiveWindow

addWindow

public final QWidget addWindow(QWidget w,
                               Qt.WindowType... flags)

Adds widget w as new sub window to the workspace. If flags are non-zero, they will override the flags set on the widget.

Returns the widget used for the window frame.

To remove the widget w from the workspace, simply call setParent with the new parent (or 0 to make it a stand-alone window).


addWindow

public final QWidget addWindow(QWidget w)

Equivalent to addWindow(w, 0).


addWindow

public final QWidget addWindow(QWidget w,
                               Qt.WindowFlags flags)

Adds widget w as new sub window to the workspace. If flags are non-zero, they will override the flags set on the widget.

Returns the widget used for the window frame.

To remove the widget w from the workspace, simply call setParent with the new parent (or 0 to make it a stand-alone window).


arrangeIcons

public final void arrangeIcons()

Arranges all iconified windows at the bottom of the workspace.

See Also:
cascade, tile

background

public final QBrush background()

Returns the workspace's background.

See Also:
setBackground

cascade

public final void cascade()

Arranges all the child windows in a cascade pattern.

See Also:
tile, arrangeIcons

closeActiveWindow

public final void closeActiveWindow()

Closes the child window that is currently active.

See Also:
closeAllWindows

closeAllWindows

public final void closeAllWindows()

Closes all child windows.

If any child window fails to accept the close event, the remaining windows will remain open.

See Also:
closeActiveWindow

scrollBarsEnabled

public final boolean scrollBarsEnabled()

Returns whether the workspace provides scroll bars.

If this property is true, the workspace will provide scroll bars if any of the child windows extend beyond the edges of the visible workspace. The workspace area will automatically increase to contain child windows if they are resized beyond the right or bottom edges of the visible area.

If this property is false (the default), resizing child windows out of the visible area of the workspace is not permitted, although it is still possible to position them partially outside the visible area.

See Also:
setScrollBarsEnabled

setActiveWindow

public final void setActiveWindow(QWidget w)

Makes the child window that contains w the active child window.

See Also:
activeWindow

setBackground

public final void setBackground(QBrush background)

Sets the workspace's background to background.

See Also:
background

setScrollBarsEnabled

public final void setScrollBarsEnabled(boolean enable)

Sets whether the workspace provides scroll bars to enable.

If this property is true, the workspace will provide scroll bars if any of the child windows extend beyond the edges of the visible workspace. The workspace area will automatically increase to contain child windows if they are resized beyond the right or bottom edges of the visible area.

If this property is false (the default), resizing child windows out of the visible area of the workspace is not permitted, although it is still possible to position them partially outside the visible area.

See Also:
scrollBarsEnabled

tile

public final void tile()

Arranges all child windows in a tile pattern.

See Also:
cascade, arrangeIcons

windowList

public final java.util.List<QWidget> windowList()
Returns a list of all visible or minimized child windows.


windowList

public final java.util.List<QWidget> windowList(QWorkspace.WindowOrder order)

Returns a list of all visible or minimized child windows. If order is CreationOrder (the default), the windows are listed 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.


changeEvent

protected void changeEvent(QEvent arg__1)

This event handler can be reimplemented to handle state changes.

The state being changed in this event can be retrieved through event arg__1.

Change events include: QEvent::ToolBarChange, QEvent::ActivationChange, QEvent::EnabledChange, QEvent::FontChange, QEvent::StyleChange, QEvent::PaletteChange, QEvent::WindowTitleChange, QEvent::IconTextChange, QEvent::ModifiedChange, QEvent::MouseTrackingChange, QEvent::ParentChange, QEvent::WindowStateChange, QEvent::LanguageChange, QEvent::LocaleChange, QEvent::LayoutDirectionChange.

Overrides:
changeEvent in class QWidget

childEvent

protected void childEvent(QChildEvent arg__1)

This event handler can be reimplemented in a subclass to receive child events. The event is passed in the arg__1 parameter.

QEvent::ChildAdded and QEvent::ChildRemoved events are sent to objects when children are added or removed. In both cases you can only rely on the child being a QObject, or if isWidgetType returns true, a QWidget. (This is because, in the ChildAdded case, the child is not yet fully constructed, and in the ChildRemoved case it might have been destructed already).

QEvent::ChildPolished events are sent to widgets when children are polished, or when polished children are added. If you receive a child polished event, the child's construction is usually completed.

For every child widget, you receive one ChildAdded event, zero or more ChildPolished events, and one ChildRemoved event.

The ChildPolished event is omitted if a child is removed immediately after it is added. If a child is polished several times during construction and destruction, you may receive several child polished events for the same child, each time with a different virtual table.

Overrides:
childEvent in class QObject
See Also:
event

event

public boolean event(QEvent e)

This is the main event handler; it handles event arg__1. You can reimplement this function in a subclass, but we recommend using one of the specialized event handlers instead.

Key press and release events are treated differently from other events. event checks for Tab and Shift+Tab and tries to move the focus appropriately. If there is no widget to move the focus to (or the key press is not Tab or Shift+Tab), event calls keyPressEvent.

Mouse and tablet event handling is also slightly special: only when the widget is enabled, event will call the specialized handlers such as mousePressEvent; otherwise it will discard the event.

This function returns true if the event was recognized, otherwise it returns false. If the recognized event was accepted (see QEvent::accepted), any further processing such as event propagation to the parent widget stops.

Overrides:
event in class QWidget
See Also:
closeEvent, focusInEvent, focusOutEvent, enterEvent, keyPressEvent, keyReleaseEvent, leaveEvent, mouseDoubleClickEvent, mouseMoveEvent, mousePressEvent, mouseReleaseEvent, moveEvent, paintEvent, resizeEvent, QObject::event, QObject::timerEvent

eventFilter

public boolean eventFilter(QObject arg__1,
                           QEvent arg__2)

Filters events if this object has been installed as an event filter for the arg__1 object.

In your reimplementation of this function, if you want to filter the arg__2 out, i.e. stop it being handled further, return true; otherwise return false.

Example:

    class MainWindow : public QMainWindow
    {
    public:
        MainWindow();

    protected:
        bool eventFilter(QObject *obj, QEvent *ev);

    private:
        QTextEdit *textEdit;
    };

    MainWindow::MainWindow()
    {
        textEdit = new QTextEdit;
        setCentralWidget(textEdit);

        textEdit->installEventFilter(this);
    }

    bool MainWindow::eventFilter(QObject *obj, QEvent *event)
    {
        if (obj == textEdit) {
            if (event->type() == QEvent::KeyPress) {
                QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
                qDebug() << "Ate key press" << keyEvent->key();
                return true;
            } else {
                return false;
            }
        } else {
            // pass the event on to the parent class
            return QMainWindow::eventFilter(obj, event);
        }
    }

Notice in the example above that unhandled events are passed to the base class's eventFilter function, since the base class might have reimplemented eventFilter for its own internal purposes.

Warning: If you delete the receiver object in this function, be sure to return true. Otherwise, Qt will forward the event to the deleted object and the program might crash.

Overrides:
eventFilter in class QObject
See Also:
installEventFilter

hideEvent

protected void hideEvent(QHideEvent e)

This event handler can be reimplemented in a subclass to receive widget hide events. The event is passed in the arg__1 parameter.

Hide events are sent to widgets immediately after they have been hidden.

Note: A widget receives spontaneous show and hide events when its mapping status is changed by the window system, e.g. a spontaneous hide event when the user minimizes the window, and a spontaneous show event when the window is restored again. After receiving a spontaneous hide event, a widget is still considered visible in the sense of isVisible.

Overrides:
hideEvent in class QWidget
See Also:
visible, event, QHideEvent

paintEvent

protected void paintEvent(QPaintEvent e)

This event handler can be reimplemented in a subclass to receive paint events which are passed in the arg__1 parameter.

A paint event is a request to repaint all or part of the widget. It can happen as a result of repaint or update, or because the widget was obscured and has now been uncovered, or for many other reasons.

Many widgets can simply repaint their entire surface when asked to, but some slow widgets need to optimize by painting only the requested region: QPaintEvent::region(). This speed optimization does not change the result, as painting is clipped to that region during event processing. QListView and QTableView do this, for example.

Qt also tries to speed up painting by merging multiple paint events into one. When update is called several times or the window system sends several paint events, Qt merges these events into one event with a larger region (see QRegion::united()). repaint does not permit this optimization, so we suggest using update whenever possible.

When the paint event occurs, the update region has normally been erased, so that you're painting on the widget's background.

The background can be set using setBackgroundRole and setPalette.

From Qt 4.0, QWidget automatically double-buffers its painting, so there's no need to write double-buffering code in paintEvent to avoid flicker.

Note: Under X11 it is possible to toggle the global double buffering by calling qt_x11_set_global_double_buffer(). Example usage:

    ...
    extern void qt_x11_set_global_double_buffer(bool);
    qt_x11_set_global_double_buffer(false);
    ...

Note: In general, one should refrain from calling update or repaint inside of paintEvent. For example, calling update or repaint on children inside a paintEvent results in undefined behavior; the child may or may not get a paint event.

Overrides:
paintEvent in class QWidget
See Also:
event, repaint, update, QPainter, QPixmap, QPaintEvent, Analog Clock Example

resizeEvent

protected void resizeEvent(QResizeEvent arg__1)

This event handler can be reimplemented in a subclass to receive widget resize events which are passed in the arg__1 parameter. When resizeEvent is called, the widget already has its new geometry. The old size is accessible through QResizeEvent::oldSize().

The widget will be erased and receive a paint event immediately after processing the resize event. No drawing need be (or should be) done inside this handler.

Overrides:
resizeEvent in class QWidget
See Also:
moveEvent, event, resize, QResizeEvent, paintEvent, Example

showEvent

protected void showEvent(QShowEvent e)

This event handler can be reimplemented in a subclass to receive widget show events which are passed in the arg__1 parameter.

Non-spontaneous show events are sent to widgets immediately before they are shown. The spontaneous show events of windows are delivered afterwards.

Note: A widget receives spontaneous show and hide events when its mapping status is changed by the window system, e.g. a spontaneous hide event when the user minimizes the window, and a spontaneous show event when the window is restored again. After receiving a spontaneous hide event, a widget is still considered visible in the sense of isVisible.

Overrides:
showEvent in class QWidget
See Also:
visible, event, QShowEvent

sizeHint

public QSize sizeHint()

Returns the recommended size for the widget.

If the value of this property is an invalid size, no size is recommended.

The default implementation of sizeHint returns an invalid size if there is no layout for this widget, and returns the layout's preferred size otherwise.

Overrides:
sizeHint in class QWidget
See Also:
QSize::isValid, minimumSizeHint, sizePolicy, setMinimumSize, updateGeometry

wheelEvent

protected void wheelEvent(QWheelEvent e)

This event handler, for event arg__1, can be reimplemented in a subclass to receive wheel events for the widget.

If you reimplement this handler, it is very important that you ignore() the event if you do not handle it, so that the widget's parent can interpret it.

The default implementation ignores the event.

Overrides:
wheelEvent in class QWidget
See Also:
QWheelEvent::ignore, QWheelEvent::accept, event, QWheelEvent

fromNativePointer

public static QWorkspace fromNativePointer(QNativePointer nativePointer)
This function returns the QWorkspace instance pointed to by nativePointer

Parameters:
nativePointer - the QNativePointer of which object should be returned.

Qt Jambi Home