Author Topic: Detecting screen resolution  (Read 3897 times)

vanstrien

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
    • http://www.vanstrien.net
Detecting screen resolution
« on: September 19, 2004, 04:37:29 am »
I'm writing a qtopia app which I would like to have a different graphical template depending on if it is running on my 5500 or 860.  Since I'm using images I will need to scale the images up by a factor if they are on the 860.

Anyone know the options for detecting the resolution (so I can then set a scale factor) from qpeapplication?  

I have looked at doing it from my main qwidget (with width() and height()) but I tend to not get the right info at the beginning of the app anyway.

I would also like to use a different layout if it is landscape versus portrait.  For this I will probably just compare the width and height.  If anyone has other suggestions please let me know.
C860 Cacko ROM | 5500 tkcROM
256MB SD | 128MB SD
512MB CF | 256MB CF
D-Link DWL 660 WiFi| Linksys WCF12 WiFi
Socket Bluetooth | Socket Ethernet

zautrix

  • Sr. Member
  • ****
  • Posts: 437
    • View Profile
    • http://www.pi-sync.net
Detecting screen resolution
« Reply #1 on: September 19, 2004, 05:54:28 am »
With

QApplication::desktop()->width()

QApplication::desktop()->height()

you will get, what you need.

z.

vanstrien

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
    • http://www.vanstrien.net
Detecting screen resolution
« Reply #2 on: September 19, 2004, 02:20:13 pm »
Thanks.  It works a treat.  I had looked around for a while but hadn't come across those...
C860 Cacko ROM | 5500 tkcROM
256MB SD | 128MB SD
512MB CF | 256MB CF
D-Link DWL 660 WiFi| Linksys WCF12 WiFi
Socket Bluetooth | Socket Ethernet

vanstrien

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
    • http://www.vanstrien.net
Detecting screen resolution
« Reply #3 on: September 26, 2004, 06:15:36 am »
Is there an event that is emitted when the screen is rotated?  

The only way I have been able to find to deal with rotation is to remember the original rotation, and if the rotation changes then scale everything to the different perspective.

ie.
  original_rotation = AppLnk::rotation();
...
void draw() {
 if (original_rotation != AppLnk::rotation()) scale();
 ...
}
C860 Cacko ROM | 5500 tkcROM
256MB SD | 128MB SD
512MB CF | 256MB CF
D-Link DWL 660 WiFi| Linksys WCF12 WiFi
Socket Bluetooth | Socket Ethernet

Mickeyl

  • Hero Member
  • *****
  • Posts: 1495
    • View Profile
    • http://www.Vanille.de
Detecting screen resolution
« Reply #4 on: September 26, 2004, 10:40:43 am »
The Opie launcher sends setRotation via QCOP to QPE/System. See
Opie-Camera for how to receive rotation notifications and act upon them.

Note that I'm not sure if Qtopia does the same.
Cheers,

Michael 'Mickey' Lauer | Embedded Linux Freelancer | www.Vanille-Media.de
Consider donating, if you like the software I contribute to.

ashikase

  • Sr. Member
  • ****
  • Posts: 280
    • View Profile
    • http://
Detecting screen resolution
« Reply #5 on: September 26, 2004, 11:56:30 am »
When the screen is rotated, it causes a QResizeEvent to be emitted. In your main widget (or any widget), you can override the 'resizeEvent' function to handle this.

For example:

Code: [Select]
void myApp::resizeEvent( QResizeEvent * ev )
{
   // change layout according to screen orientation
   if( ev->size().width() > ev->size().height() ) {
      // landscape mode
   } else {
      // portrait mode
   }

   QWidget::resizeEvent(ev);
}

- ashikase
  anpachi, gifu, japan
SL-C3100 & SL-C760