CopperSpice API  1.7.2
QScreen Class Reference

The QScreen class is used to query screen properties. More...

Inheritance diagram for QScreen:
QObject

Public Signals

void orientationChanged (Qt::ScreenOrientation orientation)
 
void primaryOrientationChanged (Qt::ScreenOrientation orientation)
 
- Public Signals inherited from QObject
void destroyed (QObject *obj=nullptr)
 
void objectNameChanged (const QString &objectName)
 

Public Methods

 ~QScreen ()
 
int angleBetween (Qt::ScreenOrientation a, Qt::ScreenOrientation b) const
 
QPixmap grabWindow (WId window, int x=0, int y=0, int width=-1, int height=-1)
 
QPlatformScreenhandle () const
 
bool isLandscape (Qt::ScreenOrientation orientation) const
 
bool isPortrait (Qt::ScreenOrientation orientation) const
 
QRect mapBetween (Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &rect) const
 
Qt::ScreenOrientation orientation () const
 
Qt::ScreenOrientations orientationUpdateMask () const
 
void setOrientationUpdateMask (Qt::ScreenOrientations mask)
 
QTransform transformBetween (Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &target) const
 
QList< QScreen * > virtualSiblings () const
 
- Public Methods inherited from QObject
 QObject (QObject *parent=nullptr)
 
 ~QObject ()
 
bool blockSignals (bool block)
 
const QList< QObject * > & children () const
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QStringdynamicPropertyNames () const
 
virtual bool event (QEvent *event)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
template<typename T >
findChild (const QString &childName=QString ()) const
 
template<class T >
QList< T > findChildren (const QRegularExpression &regExp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<class T >
QList< T > findChildren (const QString &objName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
bool inherits (const QString &className) const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const
 
bool isWindowType () const
 
void killTimer (int id)
 
const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const
 
QObject * parent () const
 
template<class T = QVariant>
property (const QString &name) const
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const QString &name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
QThreadthread () const
 

Properties

 availableGeometry
 Screen's available geometry in pixels. More...
 
 availableSize
 Screen's available size in pixels. More...
 
 availableVirtualGeometry
 Available geometry of the virtual desktop to which this screen belongs. More...
 
 availableVirtualSize
 Available size of the virtual desktop to which this screen belongs. More...
 
 depth
 Color depth of the screen. More...
 
 devicePixelRatio
 Screen's ratio between physical pixels and device-independent pixels. More...
 
 geometry
 Screen's geometry in pixels. More...
 
 logicalDotsPerInch
 Number of logical dots or pixels per inch. More...
 
 logicalDotsPerInchX
 Number of logical dots or pixels per inch in the horizontal direction. More...
 
 logicalDotsPerInchY
 Number of logical dots or pixels per inch in the vertical direction. More...
 
 name
 User presentable string representing the screen. More...
 
 nativeOrientation
 Native screen orientation. More...
 
 orientation
 Screen orientation. More...
 
 physicalDotsPerInch
 Number of physical dots or pixels per inch. More...
 
 physicalDotsPerInchX
 Number of physical dots or pixels per inch in the horizontal direction. More...
 
 physicalDotsPerInchY
 Number of physical dots or pixels per inch in the vertical direction. More...
 
 physicalSize
 Screen's physical size (in millimeters) More...
 
 refreshRate
 Approximate vertical refresh rate of the screen in Hz. More...
 
 virtualGeometry
 the pixel geometry of the virtual desktop to which this screen belongs More...
 
 virtualSize
 Pixel size of the virtual desktop to which this screen belongs. More...
 
- Properties inherited from QObject
 objectName
 

Friends

class QPlatformIntegration
 
class QPlatformScreen
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 
- Static Public Methods inherited from QObject
static bool connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ())
 
static bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...))
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod)
 
static QMetaObjectstaticMetaObject ()
 
static QString tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >())
 
- Protected Methods inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signalMethod) const
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signalMethod) const
 
bool isSignalConnected (const QMetaMethod &signalMethod) const
 
int receivers (const QString &signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 

Detailed Description

The QScreen class is used to query screen properties.

A note on logical vs physical dots per inch: physical DPI is based on the actual physical pixel sizes when available, and is useful for print preview and other cases where it's desirable to know the exact physical dimensions of screen displayed contents.

Logical dots per inch are used to convert font and user interface elements from point sizes to pixel sizes, and might be different from the physical dots per inch. The logical dots per inch are sometimes user-settable in the desktop environment's settings panel, to let the user globally control UI and font sizes in different applications.

Constructor & Destructor Documentation

QScreen::~QScreen ( )

Destroys the screen.

Method Documentation

int QScreen::angleBetween ( Qt::ScreenOrientation  a,
Qt::ScreenOrientation  b 
) const

Convenience function to compute the angle of rotation to get from rotation a to rotation b.

The result will be 0, 90, 180, or 270.

Qt::PrimaryOrientation is interpreted as the screen's primaryOrientation().

QPixmap QScreen::grabWindow ( WId  window,
int  x = 0,
int  y = 0,
int  width = -1,
int  height = -1 
)

Creates and returns a pixmap constructed by grabbing the contents of the given window restricted by QRect(x, y, width, height).

The arguments (x, y) specify the offset in the window, whereas (width, height) specify the area to be copied. If width is negative, the function copies everything to the right border of the window. If height is negative, the function copies everything to the bottom of the window.

The window system identifier (WId) can be retrieved using the QWidget::winId() function. The rationale for using a window identifier and not a QWidget, is to enable grabbing of windows that are not part of the application, window system frames, and so on.

The grabWindow() function grabs pixels from the screen, not from the window, i.e. if there is another window partially or entirely over the one you grab, you get pixels from the overlying window, too. The mouse cursor is generally not grabbed.

On X11 that if the given window does not have the same depth as the root window, and another window partially or entirely obscures the one you grab, you will not get pixels from the overlying window. The contents of the obscured areas in the pixmap will be undefined and uninitialized.

On Windows Vista and above grabbing a layered window, which is created by setting the Qt::WA_TranslucentBackground attribute, will not work. Instead grabbing the desktop widget should work.

Warning
In general grabbing an area outside the screen is not safe. This depends on the underlying window system.
QPlatformScreen * QScreen::handle ( ) const

Get the platform screen handle.

bool QScreen::isLandscape ( Qt::ScreenOrientation  orientation) const

Convenience function that returns true if orientation is either landscape or inverted landscape; otherwise returns false.

Qt::PrimaryOrientation is interpreted as the screen's primaryOrientation().

bool QScreen::isPortrait ( Qt::ScreenOrientation  orientation) const

Convenience function that returns true if orientation is either portrait or inverted portrait; otherwise returns false.

Qt::PrimaryOrientation is interpreted as the screen's primaryOrientation().

QRect QScreen::mapBetween ( Qt::ScreenOrientation  a,
Qt::ScreenOrientation  b,
const QRect rect 
) const

Maps the rect between two screen orientations.

This will flip the x and y dimensions of the rectangle rect if the orientation a is Qt::PortraitOrientation or Qt::InvertedPortraitOrientation and orientation b is Qt::LandscapeOrientation or Qt::InvertedLandscapeOrientation, or vice versa.

Qt::PrimaryOrientation is interpreted as the screen's primaryOrientation().

Qt::ScreenOrientation QScreen::orientation ( ) const

Property documentation pending.

void QScreen::orientationChanged ( Qt::ScreenOrientation  orientation)
signal

This signal is emitted when the orientation of the screen changes with orientation as an argument.

See also
orientation()
Qt::ScreenOrientations QScreen::orientationUpdateMask ( ) const

Returns the currently set orientation update mask.

See also
setOrientationUpdateMask()
void QScreen::primaryOrientationChanged ( Qt::ScreenOrientation  orientation)
signal

This signal is emitted when the primary orientation of the screen changes with orientation as an argument.

See also
primaryOrientation()
void QScreen::setOrientationUpdateMask ( Qt::ScreenOrientations  mask)

Sets the orientations that the application is interested in receiving updates for in conjunction with this screen.

As an example, to receive orientation() updates and thus have orientationChanged() signals being emitted for LandscapeOrientation and InvertedLandscapeOrientation, call setOrientationUpdateMask() with mask set to Qt::LandscapeOrientation | Qt::InvertedLandscapeOrientation.

The default of 0 means no orientationChanged() signals are emitted.

QTransform QScreen::transformBetween ( Qt::ScreenOrientation  a,
Qt::ScreenOrientation  b,
const QRect target 
) const

Convenience function to compute a transform that maps from the coordinate system defined by orientation a into the coordinate system defined by orientation b and target dimensions target.

As an example, the value for a is Qt::Landscape, the value for b is Qt::Portrait, and the value for target is QRect(0, 0, w, h). The resulting transform will place the point QPoint(0, 0) at QPoint(0, w), and QPoint(h, w) is mapped to QPoint(0, h). Thus, the landscape coordinate system QRect(0, 0, h, w) is mapped (with a 90 degree rotation) into the portrait coordinate system QRect(0, 0, w, h).

Qt::PrimaryOrientation is interpreted as the screen's primaryOrientation().

QList< QScreen * > QScreen::virtualSiblings ( ) const

Get the screen's virtual siblings.

The virtual siblings are the screen instances sharing the same virtual desktop. They share a common coordinate system, and windows can freely be moved or positioned across them without having to be recreated.

Property Documentation

QScreen::availableGeometry

The available geometry is the geometry excluding window manager reserved areas such as task bars and system menus.

PropertiesClass Methods
read availableGeometry
notify availableGeometryChanged
QScreen::availableSize

The available size is the size excluding window manager reserved areas such as task bars and system menus.

PropertiesClass Methods
read availableSize
notify availableGeometryChanged
QScreen::availableVirtualGeometry

Returns the available geometry of the virtual desktop corresponding to this screen. This is the union of the virtual siblings' individual available geometries.

See also
availableGeometry(), virtualSiblings()
PropertiesClass Methods
read availableVirtualGeometry
notify virtualGeometryChanged
QScreen::availableVirtualSize

Returns the available pixel size of the virtual desktop corresponding to this screen. This is the combined size of the virtual siblings' individual available geometries.

See also
availableSize(), virtualSiblings()
PropertiesClass Methods
read availableVirtualSize
notify virtualGeometryChanged
QScreen::depth

Color depth of the screen.

PropertiesClass Methods
read depth
constant true
QScreen::devicePixelRatio

Returns the ratio between physical pixels and device-independent pixels for the screen. Common values are 1.0 on normal displays and 2.0 on "retina" displays. Higher values are also possible.

See also
QWindow::devicePixelRatio(), QApplication::devicePixelRatio()
PropertiesClass Methods
read devicePixelRatio
notify physicalDotsPerInchChanged
QScreen::geometry

As an example this might return QRect(0, 0, 1280, 1024), or in a virtual desktop setting QRect(1280, 0, 1280, 1024).

PropertiesClass Methods
read geometry
notify geometryChanged
QScreen::logicalDotsPerInch

This value can be used to convert font point sizes to pixel sizes. This is a convenience property that's simply the average of the logicalDotsPerInchX and logicalDotsPerInchY properties.

See also
logicalDotsPerInchX(), logicalDotsPerInchY()
PropertiesClass Methods
read logicalDotsPerInch
notify logicalDotsPerInchChanged
QScreen::logicalDotsPerInchX

This value is used to convert font point sizes to pixel sizes.

See also
logicalDotsPerInchY()
PropertiesClass Methods
read logicalDotsPerInchX
notify logicalDotsPerInchChanged
QScreen::logicalDotsPerInchY

This value is used to convert font point sizes to pixel sizes.

See also
logicalDotsPerInchX()
PropertiesClass Methods
read logicalDotsPerInchY
notify logicalDotsPerInchChanged
QScreen::name

For example on X11 these correspond to the XRandr screen names, typically "VGA1", "HDMI1", etc.

PropertiesClass Methods
read name
constant true
QScreen::nativeOrientation

The native orientation of the screen is the orientation where the logo sticker of the device appears the right way up, or Qt::Primary Orientation if the platform does not support this functionality.

The native orientation is a property of the hardware, and does not change.

PropertiesClass Methods
read nativeOrientation
QScreen::orientation

The screen orientation represents the physical orientation of the display. For example, the screen orientation of a mobile device will change based on how it is being held. A change to the orientation might or might not trigger a change to the primary orientation of the screen.

Changes to this property will be filtered by orientationUpdateMask(), so in order to receive orientation updates the application must first call setOrientationUpdateMask() with a mask of the orientations it wants to receive.

Qt::PrimaryOrientation is never returned.

See also
primaryOrientation()
PropertiesClass Methods
read orientation
notify orientationChanged
QScreen::physicalDotsPerInch

This value represents the pixel density on the screen's display. Depending on what information the underlying system provides the value might not be entirely accurate.

This is a convenience property that is the average of the physicalDotsPerInchX and physicalDotsPerInchY properties.

See also
physicalDotsPerInchX(), physicalDotsPerInchY()
PropertiesClass Methods
read physicalDotsPerInch
notify physicalDotsPerInchChanged
QScreen::physicalDotsPerInchX

This value represents the actual horizontal pixel density on the screen's display. Depending on what information the underlying system provides the value might not be entirely accurate.

See also
physicalDotsPerInchY()
PropertiesClass Methods
read physicalDotsPerInchX
notify physicalDotsPerInchChanged
QScreen::physicalDotsPerInchY

This value represents the actual vertical pixel density on the screen's display. Depending on what information the underlying system provides the value might not be entirely accurate.

See also
physicalDotsPerInchX()
PropertiesClass Methods
read physicalDotsPerInchY
notify physicalDotsPerInchChanged
QScreen::physicalSize

The physical size represents the actual physical dimensions of the screen's display. Depending on what information the underlying system provides the value might not be entirely accurate.

PropertiesClass Methods
read physicalSize
notify physicalSizeChanged
QScreen::refreshRate

Approximate vertical refresh rate of the screen in Hz.

PropertiesClass Methods
read refreshRate
notify refreshRateChanged
QScreen::virtualGeometry

Returns the pixel geometry of the virtual desktop corresponding to this screen. This is the union of the virtual siblings' individual geometries.

See also
virtualSiblings()
PropertiesClass Methods
read virtualGeometry
notify virtualGeometryChanged
QScreen::virtualSize

Returns the pixel size of the virtual desktop corresponding to this screen. This is the combined size of the virtual siblings' individual geometries.

See also
virtualSiblings()
PropertiesClass Methods
read virtualSize
notify virtualGeometryChanged