Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QDesktopWidget Class

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

Header:#include <QDesktopWidget>
Inherits:QWidget

Properties

Public Functions

const QRectavailableGeometry(int screen = -1) const
const QRectavailableGeometry(const QWidget * widget) const
const QRectavailableGeometry(const QPoint & p) const
boolisVirtualDesktop() const
intprimaryScreen() const
QWidget *screen(int screen = -1)
intscreenCount() const
const QRectscreenGeometry(int screen = -1) const
const QRectscreenGeometry(const QWidget * widget) const
const QRectscreenGeometry(const QPoint & p) const
intscreenNumber(const QWidget * widget = 0) const
intscreenNumber(const QPoint & point) const

Signals

voidresized(int screen)
voidscreenCountChanged(int newCount)
voidworkAreaResized(int screen)

Reimplemented Protected Functions

virtual voidresizeEvent(QResizeEvent * event)
  • 37 protected functions inherited fromQWidget
  • 8 protected functions inherited fromQObject
  • 1 protected function inherited fromQPaintDevice

Additional Inherited Members

  • 19 public slots inherited fromQWidget
  • 1 public slot inherited fromQObject
  • 4 static public members inherited fromQWidget
  • 7 static public members inherited fromQObject
  • 37 protected functions inherited fromQWidget
  • 8 protected functions inherited fromQObject
  • 1 protected function inherited fromQPaintDevice
  • 1 protected slot inherited fromQWidget

Detailed Description

TheQDesktopWidget 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

TheQApplication::desktop() function is used to get an instance ofQDesktopWidget.

The widget'sscreenGeometry() function provides information about the geometry of the available screens with. The number of screens available is returned byscreenCount, and thescreenCountChanged() signal is emitted when screens are added or removed. The screen number that a particular point or widget is located in is returned byscreenNumber().

Screen Geometry

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

QDesktopWidget also inherits theQWidget properties,width() andheight(), 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, sowidth() andheight() shouldnot 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, thevirtualDesktop 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 theprimaryScreen 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 alsoQApplication,QApplication::desktop(), andQX11Info::appRootWindow().

Property Documentation

primaryScreen : constint

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

Access functions:

intprimaryScreen() const

screenCount : constint

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

This property was introduced in Qt 4.6.

Access functions:

intscreenCount() const

Notifier signal:

voidscreenCountChanged(int newCount)

See alsoscreenCountChanged().

virtualDesktop : constbool

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:

boolisVirtualDesktop() const

Member Function Documentation

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

Returns the available geometry of the screen with indexscreen. What is available will be subrect ofscreenGeometry() 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 ifscreen is -1.

Note:In Symbian devices the available geometry reported byQDesktopWidget 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 theworkAreaResized() signal ofQDesktopWidget.

See alsoscreenNumber() andscreenGeometry().

constQRect QDesktopWidget::availableGeometry(constQWidget * widget) const

This is an overloaded function.

Returns the available geometry of the screen which containswidget.

See alsoscreenGeometry().

constQRect QDesktopWidget::availableGeometry(constQPoint & p) const

This is an overloaded function.

Returns the available geometry of the screen which containsp.

See alsoscreenGeometry().

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

Reimplemented fromQWidget::resizeEvent().

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

This signal is emitted when the size ofscreen changes.

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

Returns a widget that represents the screen with indexscreen (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 everyscreen.

See alsoprimaryScreen,screenCount, andvirtualDesktop.

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

Returns the geometry of the screen with indexscreen. The default screen is used ifscreen is -1.

Note:In Symbian devices the screen geometry reported byQDesktopWidget 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 theresized() signal ofQDesktopWidget.

See alsoscreenNumber().

constQRect QDesktopWidget::screenGeometry(constQWidget * widget) const

This is an overloaded function.

Returns the geometry of the screen which containswidget.

constQRect QDesktopWidget::screenGeometry(constQPoint & p) const

This is an overloaded function.

Returns the geometry of the screen which containsp.

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

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

See alsoprimaryScreen.

int QDesktopWidget::screenNumber(constQPoint & point) const

This is an overloaded function.

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

See alsoprimaryScreen.

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

This signal is emitted when the work area available onscreen changes.

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.


[8]ページ先頭

©2009-2025 Movatter.jp