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

QDesktopWidget Class

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

 #include <QDesktopWidget>

Inherits: QWidget.

Public Types

enum PaintDeviceMetric { PdmWidth, PdmHeight, PdmWidthMM, PdmHeightMM, ..., PdmPhysicalDpiY }

Properties

  • 58 properties inherited from QWidget
  • 1 property inherited from QObject

Public Functions

virtual ~QPaintDevice()
const QRect availableGeometry(int screen = -1) const
const QRect availableGeometry(const QWidget * widget) const
const QRect availableGeometry(const QPoint & p) const
int colorCount() const
int depth() const
int height() const
int heightMM() const
bool isVirtualDesktop() const
int logicalDpiX() const
int logicalDpiY() const
virtual QPaintEngine * paintEngine() const = 0
bool paintingActive() const
int physicalDpiX() const
int physicalDpiY() const
int primaryScreen() const
QWidget * screen(int screen = -1)
int screenCount() const
const QRect screenGeometry(int screen = -1) const
const QRect screenGeometry(const QWidget * widget) const
const QRect screenGeometry(const QPoint & p) const
int screenNumber(const QWidget * widget = 0) const
int screenNumber(const QPoint & point) const
int width() const
int widthMM() const
  • 215 public functions inherited from QWidget
  • 31 public functions inherited from QObject

Signals

void resized(int screen)
void screenCountChanged(int newCount)
void workAreaResized(int screen)

Protected Functions

QPaintDevice()
virtual void init(QPainter * painter) const
virtual int metric(PaintDeviceMetric metric) const
virtual QPaintDevice * redirected(QPoint * offset) const
virtual QPainter * sharedPainter() const

Reimplemented Protected Functions

virtual void resizeEvent(QResizeEvent * event)
  • 37 protected functions inherited from QWidget
  • 9 protected functions inherited from QObject

Additional Inherited Members

  • 19 public slots inherited from QWidget
  • 1 public slot inherited from QObject
  • 4 static public members inherited from QWidget
  • 11 static public members inherited from QObject
  • 1 protected slot inherited from QWidget

Detailed Description

The 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 QDesktopWidget.

The widget's screenGeometry() function provides information about the geometry of the available screens with. The number of screens available is returned by screenCount, and the 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 screenNumber().

Screen Geometry

To obtain the dimensions of a particular screen, call the 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 availableGeometry() function to obtain the available area for applications.

QDesktopWidget also inherits the QWidget properties, width() and 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 width() and 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 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.

Managing Multiple Screens

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

See also QApplication and QApplication::desktop().

Property Documentation

primaryScreen : const int

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

Access functions:

int primaryScreen() const

screenCount : const int

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

This property was introduced in Qt 4.6.

Access functions:

int screenCount() const

Notifier signal:

void screenCountChanged(int newCount)

See also screenCountChanged().

virtualDesktop : const bool

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

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

Access functions:

bool isVirtualDesktop() const

Member Function Documentation

const QRect QDesktopWidget::availableGeometry(int screen = -1) const

Returns the available geometry of the screen with index screen. What is available will be subrect of 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.

See also screenNumber() and screenGeometry().

const QRect QDesktopWidget::availableGeometry(const QWidget * widget) const

This is an overloaded function.

Returns the available geometry of the screen which contains widget.

See also screenGeometry().

const QRect QDesktopWidget::availableGeometry(const QPoint & p) const

This is an overloaded function.

Returns the available geometry of the screen which contains p.

See also screenGeometry().

void QDesktopWidget::resizeEvent(QResizeEvent * event) [virtual protected]

Reimplemented from QWidget::resizeEvent().

void QDesktopWidget::resized(int screen) [signal]

This signal is emitted when the size of screen changes.

QWidget * QDesktopWidget::screen(int screen = -1)

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.

See also primaryScreen, screenCount, and virtualDesktop.

const QRect QDesktopWidget::screenGeometry(int screen = -1) const

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

See also screenNumber().

const QRect QDesktopWidget::screenGeometry(const QWidget * widget) const

This is an overloaded function.

Returns the geometry of the screen which contains widget.

const QRect QDesktopWidget::screenGeometry(const QPoint & p) const

This is an overloaded function.

Returns the geometry of the screen which contains p.

int QDesktopWidget::screenNumber(const QWidget * widget = 0) const

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

See also primaryScreen.

int QDesktopWidget::screenNumber(const QPoint & point) const

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.

See also primaryScreen.

void QDesktopWidget::workAreaResized(int screen) [signal]

This signal is emitted when the work area available on screen changes.

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

Hébergement Web