×
Namespaces

Variants
Actions
(Difference between revisions)

Get screen coordinates in Qt

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot change of template (Template:CodeSnippet) - now using Template:ArticleMetaData)
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot update - Fix ArticleMetaData and RevieweApproval)
Line 1: Line 1:
 
[[Category:Qt]][[Category:UI]]
 
[[Category:Qt]][[Category:UI]]
{{ReviewerApproved|timestamp=20090923}}
 
  
{{ArticleMetaData
 
|id=...
 
|platform=S60 3rd Edition, FP1, FP2<br>S60 5th Edition
 
|devices=Nokia 5800 XpressMusic
 
|category=Qt
 
|subcategory=UI
 
|creationdate=June 9, 2009
 
|keywords=QDesktopWidget::availableGeometry(), QDesktopWidget::screenGeometry()
 
  
|sourcecode= <!-- Link to example source code (e.g. [[Media:The Code Example ZIP.zip]]) -->
+
{{ArticleMetaData <!-- v1.1 -->
 +
|sourcecode= [[Media:QtScreenCoordinates.zip]]  
 
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
|sdk=<!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
+
|devices= Nokia 5800 XpressMusic
|devicecompatability=<!-- Compatible devices (e.g.: All* (must have GPS) ) -->
+
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
|signing=<!-- Empty or one of Self-Signed, DevCert, Manufacturer -->
+
|platform= S60 3rd Edition, FP1, FP2<br>S60 5th Edition
|capabilities=<!-- Capabilities required (e.g. Location, NetworkServices. -->)
+
|devicecompatability= <!-- Compatible devices (e.g.: All* (must have GPS) ) -->
|author=[[User:Savaj]]
+
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 +
|signing= <!-- Empty or one of Self-Signed, DevCert, Manufacturer -->
 +
|capabilities= <!-- Capabilities required (e.g. Location, NetworkServices. -->)
 +
|keywords= QDesktopWidget::availableGeometry(), QDesktopWidget::screenGeometry()
 +
|id= ...
 +
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 +
|translated-by= <!-- [[User:XXXX]] -->
 +
|translated-from-title= <!-- Title only -->
 +
|translated-from-id= <!-- Id of translated revision -->
 +
|review-by= <!-- After re-review: [[User:username]] -->
 +
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 +
|update-by= <!-- After significant update: [[User:username]]-->
 +
|update-timestamp= <!-- After significant update: YYYYMMDD -->
 +
|creationdate= 20090609
 +
|author= [[User:Savaj]]
 +
<!-- The following are not in current metadata -->
 +
|subcategory= UI
 +
|category= Qt
 
}}
 
}}
  

Revision as of 07:36, 10 February 2012


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

Contents

Overview

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.

Preconditions

  • Download and install the Qt SDK.

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

191 page views in the last 30 days.
×