Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Contributor
misugijunz
Posts: 24
Registered: ‎12-27-2011
My Device: Torch 9810 | PlayBook
Accepted Solution

QtQuick App Resize Problem

I ran into another problem while porting a QtQuick app. It is a screen orientation lock and resize. 

When the application start first after built, it runs normal as expected but for the after tries it will behave unexpectedly.

 

For example, when I tried to make the phone portrait and start the application, its view will open in portrait and stretched, and when I tried to make the phone landscape again and restarting the application, it stretched also to the

half screen, the view is messed up. several items put on the qml are messed also.

 

I observed the problem caused by these lines of code. I already commented the second line, which improves the result close to my expectation but I'm still unable lock the qml view orientation. Any suggestion?

 

view.setAttribute(Qt::WA_LockLandscapeOrientation,true);
view.setResizeMode(QDeclarativeView::SizeRootObjectToView);
view.showMaximized();
Contributor
mcguire
Posts: 24
Registered: ‎09-10-2012
My Device: Blackberry Dev Alpha

Re: QtQuick App Resize Problem

Qt::WA_LockLandScapeOrientation is not yet supported for Blackberry devices.

 

Instead, you can add something like the following to your bar-descriptor XML file:

 

<initialWindow>
        <autoOrients>false</autoOrients>
        <aspectRatio>landscape</aspectRatio>
</initialWindow>

 About the other problem: Could you post a minimal testcase of this, please? Then we (KDAB) can have a look.

Contributor
misugijunz
Posts: 24
Registered: ‎12-27-2011
My Device: Torch 9810 | PlayBook

Re: QtQuick App Resize Problem

[ Edited ]

Yes, I had put this one before:

 

<initialWindow>
        <autoOrients>false</autoOrients>
        <aspectRatio>landscape</aspectRatio>
</initialWindow>

 

I haven't experienced the problem before b3 bb10 software.

 

Test case:

 

1. Create an image area contains of couple image area and component, for example: 

https://gist.github.com/84889e651d3d2c91560c

 

2. Build it

 

3. Run it

 

4. Looks normal, looking good, no problem

 

5. Close it.

 

6. Stand the device vertically, screen front facing

 

7. run it again

 

8. It will stretched unexpectedly

 

 

IMG_00000017.png

9. Close it again, stand the device horizontally, screen front facing

10. run it again

11. It stretched vertically (it doesn't always happen, sometimes it will load the application just like (8), or stretched half screen with the half other is a white one (background color) )

IMG_00000016.png

 

11. Sometimes it gets normal again, and screwed up for next tries.

12. Expected result, it should be looks nice and crisp (this is the look that I get after build or when the application becomes normal again sometimes)

mainmenu.png

 

Thanks!

Contributor
mcguire
Posts: 24
Registered: ‎09-10-2012
My Device: Blackberry Dev Alpha

Re: QtQuick App Resize Problem

Thanks for the testcase, I'll have a look as soon as I get to it (have to work through a pile of other bugs in my backlog first)

Contributor
mcguire
Posts: 24
Registered: ‎09-10-2012
My Device: Blackberry Dev Alpha

Re: QtQuick App Resize Problem

While looking at https://gist.github.com/84889e651d3d2c91560c, I noticed some conflicting positioners. For example the "logo" image has both "x" and "anchors.left" set. These conflict, you can either use absolute positioning or anchor-based positioning, but noth both at the same time. Or rather, you can combine both, but they can not both define the same layouting attribute. In this case, "x" and "anchors.left" define the same layouting attribute, namely the leftmost position of the element. Combining "anchors.top" and "x" on the other hand would be fine, as they define different layouting attributes, the topmost and the leftmost position.

 

Same for the "menu" element btw, "anchors.fill" and "x", "y" conflict.

 

I don't know what QtQuick does in case of these conflicts, and it is probably unrelated to the bug you're seeing, but I thought I'd mention it so you can create cleaner and more bug-free QML code.

Contributor
mcguire
Posts: 24
Registered: ‎09-10-2012
My Device: Blackberry Dev Alpha

Re: QtQuick App Resize Problem

I can not reproduce the problem.

I created a simple QML file with 2 images, and then launched the application a few times, alternating between horizontal and vertical orientation of the device. I didn't see any stretching yet.

 

I've uploaded the testcase I used to http://www.kdab.com/~thomas/stuff/qtquick-stretch-test.tar.gz, please try it and report if it works for you (you might need to adjust the bar descriptor file). If you don't see the bug with that example, please modify it until your bug appears, and then re-upload it somewhere.

I need a minimal testcase that reproduces the bug to be able to do something about it.

BlackBerry Development Advisor
fbumberger
Posts: 5
Registered: ‎10-04-2012
My Device: Playbook

Re: QtQuick App Resize Problem

Please don't use showMaximized(). Use showFullScreen() instead
Contributor
misugijunz
Posts: 24
Registered: ‎12-27-2011
My Device: Torch 9810 | PlayBook

Re: QtQuick App Resize Problem

@mcguire, i'll try it shortly..

 

@fbumberger, I already did, change to showFullScreen() didn't change the result..

Contributor
mcguire
Posts: 24
Registered: ‎09-10-2012
My Device: Blackberry Dev Alpha

Re: QtQuick App Resize Problem

Btw, we are fixing WA_LockLandscape at the moment, see https://codereview.qt-project.org/#change,36296.

Contributor
misugijunz
Posts: 24
Registered: ‎12-27-2011
My Device: Torch 9810 | PlayBook

Re: QtQuick App Resize Problem

[ Edited ]

Hi I put the implementation on my main cpp like this:

 

#ifdef Q_OS_BLACKBERRY
navigator_set_orientation_mode(NAVIGATOR_LANDSCAPE, 0);
navigator_rotation_lock(true);
#else
view.setAttribute(Qt::WA_NoSystemBackground);
view.setAttribute(Qt::WA_AutoOrientation, false);
view.setAttribute(Qt::WA_LockLandscapeOrientation, true);
#endif
view.setResizeMode(QDeclarativeView::SizeRootObjectToView);
view.showFullScreen();

It is still not able to lock on landscape mode when it ran in which device held vertically or when it ran horizontally an then hold the device vertically (it rotated to portrait mode and all element fitted to the screen, all showed but skewed/slimmed).

 

However, I noticed an improvement when changing autoorients value in bar descriptor to true:

> It is more consistent. When the device held in landscape, all elements are in the normal position. It doesn't stretched  unexpectedly like before (showed on picture above), when the device held in portrait (rotated counter clockwise), all elements rotated clockwise. The only thing left is to block its rotation to portrait.

 

nb: I'm using 'fillMode: Image.Stretch' which is not in your test case.