QDesktopWidget

Synopsis

Functions

Signals

Detailed Description

The PySide.QtGui.QDesktopWidget class provides access to screen information on multi-head systems.

Systems with more than one graphics card and monitor can manage the physical screen space available either as multiple desktops, or as a large virtual desktop.

This class provides information about the user’s desktop, such as its total size, number of screens, the geometry of each screen, and whether they are configured as separate desktops or a single virtual desktop.

Widgets provided by Qt use this class to place tooltips, menus and dialog boxes on the correct screen for their parent or application widgets. Applications can use this class to obtain information that can be used to save window positions, or to place child widgets and dialogs on one particular screen.

Obtaining a Desktop Widget

The QApplication.desktop() function is used to get an instance of PySide.QtGui.QDesktopWidget .

The widget’s PySide.QtGui.QDesktopWidget.screenGeometry() function provides information about the geometry of the available screens with. The number of screens available is returned by PySide.QtGui.QDesktopWidget.screenCount() , and the PySide.QtGui.QDesktopWidget.screenCountChanged() signal is emitted when screens are added or removed. The screen number that a particular point or widget is located in is returned by PySide.QtGui.QDesktopWidget.screenNumber() .

Screen Geometry

To obtain the dimensions of a particular screen, call the PySide.QtGui.QDesktopWidget.screenGeometry() function. On some desktop environments, not all of the screen is available for applications to use; for example, an application dock or menu bar may take up some space. Use the PySide.QtGui.QDesktopWidget.availableGeometry() function to obtain the available area for applications.

PySide.QtGui.QDesktopWidget also inherits the PySide.QtGui.QWidget properties, PySide.QtGui.QWidget.width() and PySide.QtGui.QWidget.height() , which specify the size of the desktop. However, for desktops with multiple screens, the size of the desktop is the union of all the screen sizes, so PySide.QtGui.QWidget.width() and PySide.QtGui.QWidget.height() should not be used for computing the size of a widget to be placed on one of the screens.

On systems that are configured to use the available screens as a single, large virtual desktop, the virtualDesktop() property will be set to true. In this case, the widget’s size is usually the size of the bounding rectangle of all the screens.

Use of the Primary Screen

For an application, the screen where the main widget resides is the primary screen. This is stored in the PySide.QtGui.QDesktopWidget.primaryScreen() property. All windows opened in the context of the application should be constrained to the boundaries of the primary screen; for example, it would be inconvenient if a dialog box popped up on a different screen, or split over two screens.

../../_images/qdesktopwidget.png

In the illustration above, Application One’s primary screen is screen 0, and App Two’s primary screen is screen 1.

See also

PySide.QtGui.QApplication QApplication.desktop() QX11Info.appRootWindow()

class PySide.QtGui.QDesktopWidget

Creates the desktop widget.

If the system supports a virtual desktop, this widget will have the size of the virtual desktop; otherwise this widget will have the size of the primary screen.

Instead of using PySide.QtGui.QDesktopWidget directly, use QApplication.desktop() .

PySide.QtGui.QDesktopWidget.availableGeometry(widget)
Parameters:widgetPySide.QtGui.QWidget
Return type:PySide.QtCore.QRect

This is an overloaded function.

Returns the available geometry of the screen which contains widget .

PySide.QtGui.QDesktopWidget.availableGeometry([screen=-1])
Parameters:screenPySide.QtCore.int
Return type:PySide.QtCore.QRect

Returns the available geometry of the screen with index screen . What is available will be subrect of PySide.QtGui.QDesktopWidget.screenGeometry() based on what the platform decides is available (for example excludes the dock and menu bar on Mac OS X, or the task bar on Windows). The default screen is used if screen is -1.

Note

In Symbian devices the available geometry reported by PySide.QtGui.QDesktopWidget is not guaranteed to be correct at the time the geometry change resize event is passed to widgets. The correct way to listen for available geometry changes is to connect to the PySide.QtGui.QDesktopWidget.workAreaResized() signal of PySide.QtGui.QDesktopWidget .

PySide.QtGui.QDesktopWidget.availableGeometry(point)
Parameters:pointPySide.QtCore.QPoint
Return type:PySide.QtCore.QRect

This is an overloaded function.

Returns the available geometry of the screen which contains p .

PySide.QtGui.QDesktopWidget.isVirtualDesktop()
Return type:PySide.QtCore.bool

This property holds if the system manages the available screens in a virtual desktop..

For virtual desktops, PySide.QtGui.QDesktopWidget.screen() will always return the same widget. The size of the virtual desktop is the size of this desktop widget.

PySide.QtGui.QDesktopWidget.numScreens()
Return type:PySide.QtCore.int

Returns the number of available screens.

This function is deprecated. Use PySide.QtGui.QDesktopWidget.screenCount() instead.

PySide.QtGui.QDesktopWidget.primaryScreen()
Return type:PySide.QtCore.int

This property holds the index of the screen that is configured to be the primary screen on the system..

PySide.QtGui.QDesktopWidget.resized(arg__1)
Parameters:arg__1PySide.QtCore.int
PySide.QtGui.QDesktopWidget.screen([screen=-1])
Parameters:screenPySide.QtCore.int
Return type:PySide.QtGui.QWidget

Returns a widget that represents the screen with index screen (a value of -1 means the default screen).

If the system uses a virtual desktop, the returned widget will have the geometry of the entire virtual desktop; i.e., bounding every screen .

PySide.QtGui.QDesktopWidget.screenCount()
Return type:PySide.QtCore.int

This property holds the number of screens currently available on the system..

PySide.QtGui.QDesktopWidget.screenCountChanged(arg__1)
Parameters:arg__1PySide.QtCore.int
PySide.QtGui.QDesktopWidget.screenGeometry(point)
Parameters:pointPySide.QtCore.QPoint
Return type:PySide.QtCore.QRect

This is an overloaded function.

Returns the geometry of the screen which contains p .

PySide.QtGui.QDesktopWidget.screenGeometry(widget)
Parameters:widgetPySide.QtGui.QWidget
Return type:PySide.QtCore.QRect

This is an overloaded function.

Returns the geometry of the screen which contains widget .

PySide.QtGui.QDesktopWidget.screenGeometry([screen=-1])
Parameters:screenPySide.QtCore.int
Return type:PySide.QtCore.QRect

Returns the geometry of the screen with index screen . The default screen is used if screen is -1.

Note

In Symbian devices the screen geometry reported by PySide.QtGui.QDesktopWidget is not guaranteed to be correct at the time the geometry change resize event is passed to widgets. The correct way to listen for screen geometry changes is to connect to the PySide.QtGui.QDesktopWidget.resized() signal of PySide.QtGui.QDesktopWidget .

PySide.QtGui.QDesktopWidget.screenNumber([widget=None])
Parameters:widgetPySide.QtGui.QWidget
Return type:PySide.QtCore.int

Returns the index of the screen that contains the largest part of widget , or -1 if the widget not on a screen.

PySide.QtGui.QDesktopWidget.screenNumber(arg__1)
Parameters:arg__1PySide.QtCore.QPoint
Return type:PySide.QtCore.int

This is an overloaded function.

Returns the index of the screen that contains the point , or the screen which is the shortest distance from the point .

PySide.QtGui.QDesktopWidget.workAreaResized(arg__1)
Parameters:arg__1PySide.QtCore.int