Results 1 to 4 of 4

Thread: [Android] volatile size of screen

  1. #1
    Join Date
    Nov 2010
    Posts
    31
    Thanks
    11
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default [Android] volatile size of screen

    Hi all,

    First of all sorry if it's not quite appropriate forum to ask about Qt on Android, but why not to try

    I have application that goes full screen and uses QGraphicsView to display content, I locked application in Landscape view.
    It looks like sometimes I got screen height lets say 316 px and sometime 297 pix on a device Sony Xperia Tipo that has resolution 480x320 (keep in mind that my app is working in landscape mode)
    I'm pretty sure that this is because this android taskabar that is displayed at the top, sometimes application takes it into account, and then screen height is 297px and sometime not, and I have 316px. This happens totally random, and in both cases application goes full screen and obscures this Android task-bar.
    Does anyone expected such a behavior and maybe knows how to deal with it ?

    I'm using Necessitas 4.8.2 for armv7 (gcc arm-4.4.3) on Linux Squeeze

    Many thanks in advance
    Marek

  2. #2
    Join Date
    May 2011
    Posts
    239
    Thanks
    4
    Thanked 35 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Symbian S60

    Default Re: [Android] volatile size of screen

    (Well, what could be a more appopriate forum for Qt questions?)

    I have no knowledge why that is, but just two ideas:
    1) Randomeness might point to there being two concurrent processes which are not synchronized. For that I would place a small delay (or the traditional QApplication::ProcessEvents()) somewhere to let the system stabilize before checking the height.
    2) The actual function you use to get "screen" height might matter -- I'm sure there are alternatives. Showing the actual code (!) is _always_ a good idea.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: [Android] volatile size of screen

    Have you tried showing the window maximized instead of fullscreen?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Nov 2010
    Posts
    31
    Thanks
    11
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: [Android] volatile size of screen

    Hello,

    Regarding the actual function that I use to get screen height:
    I have subclassed QGraphicsView and putted it on on first QStackedWidget page stretched to full screen.
    I'm getting screen resolution from events
    Qt Code:
    1. void MGraphicsView::showEvent(QShowEvent *event) {
    2. QGraphicsView::showEvent(event);
    3. emit viewSet(this->viewport()->geometry().width(),this->viewport()->geometry().height());
    4. }
    5. void MGraphicsView::resizeEvent(QResizeEvent *event) {
    6. QGraphicsView::resizeEvent(event);
    7. emit viewResized(this->viewport()->geometry().width(),this->viewport()->geometry().height());
    8. }
    To copy to clipboard, switch view to plain text mode 

    Starting my app first time, it is doing some registration with my home server, and during this I used to save this resolution into application config file, so next time when app was starting I didn't have to wait for showEvent, I could paint and position elements before it, which was convenient for me.

    Regarding the showFullScreen and showMaximized, with the later there is always this task bar visible at the top. I'm not sure if I want it to be visible Haven't decided yet.

    Regarding the concurrent processes, I think it may be some race condition between java and Qt ?
    During both cases I have slightly different debug output during application startup, and it differs because some internal messages from dalvik machine, or/and java.
    I have included some debug for both cases.
    I think that delay or QApplication::ProcessEvents() would be a goood idea, but where to put it? in main before creating main window? or before creating object mainView which uses subclassed QGraphicsView ?

    best regards
    Marek
    Attached Files Attached Files

Similar Threads

  1. Problem scalng the Screen size
    By baluk in forum Newbie
    Replies: 2
    Last Post: 23rd November 2010, 15:50
  2. Image - screen size
    By ahmdsd_ostora in forum Qt Programming
    Replies: 2
    Last Post: 11th July 2010, 15:29
  3. how to get screen pixel size?
    By kodiak in forum Qt Programming
    Replies: 6
    Last Post: 26th August 2008, 18:59
  4. screen size
    By eric in forum Qt Programming
    Replies: 2
    Last Post: 28th December 2007, 14:54
  5. how to get the screen size in qt2
    By pencilren in forum Qt Programming
    Replies: 2
    Last Post: 22nd June 2007, 03:47

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.