QDesktopWidget(3qt)
π QDesktopWidget π
okay bestie, so this is QDesktopWidget, and it lives in the 3qt manual, and it's literally the class that lets you peek at ALL your screens on a multi-head system. no cap. if you've ever had a dialog box pop up on the wrong monitor and wanted to scream, this class is your girl. π¦
β¨ NAME β¨
QDesktopWidget β access to screen information on multi-head systems π
πΈ SYNOPSIS πΈ
#include <qdesktopwidget.h>
Inherits QWidget.
π Public Members
QDesktopWidget ()
~QDesktopWidget ()
bool isVirtualDesktop () const
int numScreens () const
int primaryScreen () const
int screenNumber ( QWidget * widget = 0 ) const
int screenNumber ( const QPoint & point ) const
QWidget * screen ( int screen = -1 )
const QRect & screenGeometry ( int screen = -1 ) const
const QRect & screenGeometry ( QWidget * widget ) const
const QRect & screenGeometry ( const QPoint & p ) const
const QRect & availableGeometry ( int screen = -1 ) const
const QRect & availableGeometry ( QWidget * widget ) const
const QRect & availableGeometry ( const QPoint & p ) const
π« Signals
void resized ( int screen )
π DESCRIPTION π
The QDesktopWidget class provides access to screen information on multi-head systems. it's giving "I know where every single pixel of your setup lives." π
okay so picture this: 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 (peep isVirtualDesktop() for that one). for an application, one of the available screens is the primary screen, i.e. the screen where the main widget resides (see primaryScreen()). and here's the important part, bestie: all windows opened in the context of the application must 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. like imagine that. a dialog split across two monitors. absolutely not. π
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. lowkey iconic behaviour tbh.
Applications can use this class to save window positions, or to place child widgets on one screen.
<center> [Image Omitted] </center>
In the illustration above, Application One's primary screen is screen 0, and App Two's primary screen is screen 1. πΈ
See also Advanced Widgets and Environment Classes.
π§ 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.
bestie, real talk: instead of usingQDesktopWidgetdirectly, useQApplication::desktop(). do NOT come for me, that's just the way it is. π«Ά
β QDesktopWidget::~QDesktopWidget ()
Destroy the object and free allocated resources. it's the farewell tour. π
β 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 Menubar on Mac OS X, or the taskbar on Windows). so like, the usable vibe of your screen, minus the furniture. π
See also screenNumber() and screenGeometry().
β const QRect & QDesktopWidget::availableGeometry ( QWidget * widget ) const
This is an overloaded member function, provided for convenience. It behaves essentially like the above 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 member function, provided for convenience. It behaves essentially like the above function.
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. one big screen energy fr fr. π
β int QDesktopWidget::numScreens () const
Returns the number of available screens. count 'em, bestie. π
See also primaryScreen().
β int QDesktopWidget::primaryScreen () const
Returns the index of the primary screen. the main character of your monitors. π
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. This widget can be used to draw directly on the desktop, using an unclipped painter like this:
QPainter paint( QApplication::desktop()->screen( 0 ), TRUE );
paint.draw...
...
paint.end();
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 ( QWidget * widget ) const
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
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. It behaves essentially like the above function.
Returns the geometry of the screen which contains p. πΈ
β int QDesktopWidget::screenNumber ( 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. (yes, -1 means "no screen bestie, she's floating" π)
See also primaryScreen().
β int QDesktopWidget::screenNumber ( const QPoint & point ) const
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Returns the index of the screen that contains point, or -1 if no screen contains the point.
See also primaryScreen().
π SEE ALSO π
π COPYRIGHT π
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement.
βοΈ AUTHOR βοΈ
Generated automatically from the source code. (so no, a human did not hand-write this one, the machine did it. still slayed tho. π )
π BUGS π
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you. π«Ά
The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech.
If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qdesktopwidget.3qt) and the Qt version (3.3.8). bestie the version number matters, don't be shy with it. π
and that's the whole thing! this page came straight outta the Trolltech AS era β dated 2 February 2007 β and it's filed under QDesktopWidget(3qt) in the manual. mwah, go forth and put your dialogs on the right screen. πβ¨ππ¦πΈπ
π
π¦ where this page comes from
- fedora 43: qt3-devel-docs 3.3.8b-102.fc43 Β· QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- fedora 44: qt3-devel-docs 3.3.8b-103.fc44 Β· QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms