×
Namespaces

Variants
Actions
(Difference between revisions)

Get screen coordinates in Qt

From Nokia Developer Wiki
Jump to: navigation, search
kiran10182 (Talk | contribs)
m (Qt for Symbian -> Qt)
hamishwillee (Talk | contribs)
m (Add Abstract. Point to correct Qt SDK)
Line 1: Line 1:
 
[[Category:Qt]][[Category:UI]]
 
[[Category:Qt]][[Category:UI]]
{{ReviewerApproved}}
+
{{ReviewerApproved|timestamp=20090923}}
  
 
{{CodeSnippet
 
{{CodeSnippet
Line 14: Line 14:
 
==Overview==
 
==Overview==
  
This code snippets shows how to get screen coordinates/screen size in 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().
+
{{Abstract|visible=true|This code example shows how to get screen coordinates and screen size in a Qt application. The API [http://doc.qt.nokia.com/stable/qdesktopwidget.html QDesktopWidget::screenGeometry()] returns the application rect (screen size of device) and API {{Icode|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 {{Icode|QWidget::resizeEvent()}}.}}
  
This snippet can be self-signed. As it does not use any API which require developer/symbian signed certificate.
+
This snippet can be self-signed.
  
 
==Preconditions==
 
==Preconditions==
  
* Download and Install latest version [[Qt for Symbian - Installation packages]] which has links on how to install the latest version
+
* Download and install the [[Qt SDK]].
  
 
==Source==
 
==Source==
Line 46: Line 46:
 
==Code Example==
 
==Code Example==
  
* The [[Media:QtScreenCoordinates.zip|Code Example]] shows screen coordinates on screen and example is tested on Nokia 5800 XpressMusic.
+
* [[File:QtScreenCoordinates.zip]] shows screen coordinates on screen and example is tested on Nokia 5800 XpressMusic.
<br>
+
  
  
 
[[Category:Code Examples]]
 
[[Category:Code Examples]]

Revision as of 02:31, 26 April 2011

{{{width}}}
23 Sep
2009
Article Metadata
Tested with
Devices(s): Nokia 5800 XpressMusic
Compatibility
Platform(s): S60 3rd Edition, FP1, FP2
S60 5th Edition
Symbian
Article
Keywords: QDesktopWidget::availableGeometry(), QDesktopWidget::screenGeometry()
Created: (09 Jun 2009)
Last edited: hamishwillee (26 Apr 2011)

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

200 page views in the last 30 days.
×