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  ·  Tous les espaces de nom  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QDesktopWidget Class Reference
[QtGui module]

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

 #include <QDesktopWidget>

Inherits QWidget.

Public Functions

  • 206 public functions inherited from QWidget
  • 29 public functions inherited from QObject
  • 12 public functions inherited from QPaintDevice

Signals

Additional Inherited Members

  • 57 properties inherited from QWidget
  • 1 property inherited from QObject
  • 19 public slots inherited from QWidget
  • 1 public slot inherited from QObject
  • 4 static public members inherited from QWidget
  • 5 static public members inherited from QObject
  • 38 protected functions inherited from QWidget
  • 7 protected functions inherited from QObject
  • 1 protected function inherited from QPaintDevice
  • 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, which usually has the size of the bounding rectangle of all the screens (see isVirtualDesktop()). For an application, one of the available screens is the primary screen, i.e. the screen where the main widget resides (see primaryScreen()). 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.

The QDesktopWidget provides information about the geometry of the available screens with screenGeometry(). The number of screens available is returned by numScreens(). The screen number that a particular point or widget is located in is returned by screenNumber().

Widgets provided by Qt use this class, for example, to place tooltips, menus and dialog boxes according to the parent or application widget.

Applications can use this class to save window positions, or to place child widgets on one screen.

Managing Multiple Screens

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

Note: QDesktopWidget 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. The correct width and height values are obtained using availableGeometry() or screenGeometry() for a particular screen.

See also QApplication and QX11Info::appRootWindow().


Member Function Documentation

QDesktopWidget::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 QDesktopWidget directly, use QApplication::desktop().

QDesktopWidget::~QDesktopWidget ()

Destroys the desktop widget and frees any allocated resources.

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

See also screenNumber() and screenGeometry().

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

This is an overloaded member function, provided for convenience.

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 member function, provided for convenience.

Returns the available geometry of the screen which contains p.

See also screenGeometry().

bool QDesktopWidget::isVirtualDesktop () const

Returns true if the system manages the available screens in a virtual desktop; otherwise returns false.

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

int QDesktopWidget::numScreens () const

Returns the number of available screens.

See also primaryScreen().

int QDesktopWidget::primaryScreen () const

Returns the index of the primary screen.

See also numScreens().

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.

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(), numScreens(), and isVirtualDesktop().

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

Returns the geometry of the screen with index screen.

See also screenNumber().

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

This is an overloaded member function, provided for convenience.

Returns the geometry of the screen which contains widget.

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

This is an overloaded member function, provided for convenience.

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 member function, provided for convenience.

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.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 94
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 42
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 9
  7. Qt Commercial : Digia organise un webinar gratuit le 27 mars sur la conception d'interfaces utilisateur et d'applications avec le framework 0
Page suivante

Le blog Digia au hasard

Logo

Créer des applications avec un style Metro avec Qt, exemples en QML et C++, un article de Digia Qt traduit par Thibaut Cuvelier

Le blog Digia est l'endroit privilégié pour la communication sur l'édition commerciale de Qt, où des réponses publiques sont apportées aux questions les plus posées au support. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

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 4.4
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