PDA

View Full Version : [Android] volatile size of screen



franki
9th January 2013, 15:52
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

mvuori
9th January 2013, 20:23
(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.

wysota
9th January 2013, 21:01
Have you tried showing the window maximized instead of fullscreen?

franki
10th January 2013, 08:54
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


void MGraphicsView::showEvent(QShowEvent *event) {
QGraphicsView::showEvent(event);
emit viewSet(this->viewport()->geometry().width(),this->viewport()->geometry().height());
}
void MGraphicsView::resizeEvent(QResizeEvent *event) {
QGraphicsView::resizeEvent(event);
emit viewResized(this->viewport()->geometry().width(),this->viewport()->geometry().height());
}


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