Get screen coordinates in Qt
m (Add Abstract. Point to correct Qt SDK)
m (moved Get screen coordinates in Qt for Symbian to Get screen coordinates in Qt over redirect: "for symbian" in name not required)
Revision as of 02:31, 26 April 2011
S60 5th Edition
This code example shows how to get screen coordinates and screen size in a Qt application. The API QDesktopWidget::screenGeometry() returns the application rect (screen size of device) and API QDesktopWidget::availableGeometry() returns client rect (screen size minus status pane). It is useful in UI applications that do not use layout managers by implementing virtual QWidget::resizeEvent().
This snippet can be self-signed.
- Download and install the Qt SDK.
QDesktopWidget* desktopWidget = QApplication::desktop();
//get client rect.
QRect clientRect = desktopWidget->availableGeometry();
//get application rect.
QRect applicationRect = desktopWidget->screenGeometry();
You will get application rect.
- File:QtScreenCoordinates.zip shows screen coordinates on screen and example is tested on Nokia 5800 XpressMusic.