×
Namespaces

Variants
Actions
(Difference between revisions)

Get screen coordinates in Qt

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
m (Hamishwillee - Addition to article of: Category:MeeGo Category:Symbian. (Add platform categories))
hamishwillee (Talk | contribs)
m (Text replace - "Category:MeeGo" to "Category:MeeGo Harmattan")
Line 49: Line 49:
 
==Code Example==
 
==Code Example==
  
* [[File:QtScreenCoordinates.zip]] shows screen coordinates on screen and example is tested on Nokia 5800 XpressMusic.[[Category:MeeGo]] [[Category:Symbian]]
+
* [[File:QtScreenCoordinates.zip]] shows screen coordinates on screen and example is tested on Nokia 5800 XpressMusic.[[Category:MeeGo Harmattan]] [[Category:Symbian]]

Revision as of 13:53, 13 June 2012

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

Article Metadata
Code ExampleTested with
Devices(s): Nokia 5800 XpressMusic
Compatibility
Platform(s): S60 3rd Edition, FP1, FP2
S60 5th Edition
Symbian
Platform Security
Signing Required: Self-Signed
Capabilities: None
Article
Keywords: QDesktopWidget::availableGeometry(), QDesktopWidget::screenGeometry()
Created: savaj (09 Jun 2009)
Last edited: hamishwillee (13 Jun 2012)

Source

QDesktopWidget* desktopWidget = QApplication::desktop();
//get client rect.
QRect clientRect = desktopWidget->availableGeometry();
 
//get application rect.
QRect applicationRect = desktopWidget->screenGeometry();


Postconditions

You will get application rect.

Screen Coordinates for 640x360

ScreenCoordinates2.JPG

Screen Coordinates for 360x640

ScreenCoordinates1.JPG

Code Example

180 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×