Question

I picked up the development for an abandoned Qt app about a month ago. It's almost complete, but I'm facing one bug that I can't manage to fix. When I simulate the app, everything works fine, both portrait as landscape. However, when I install the app on my Nokia E7-00 running on nokia belle refresh (Qt 4.8), landscape mode breaks. Is there any solution to this? I found 1 topic that described similar problems, but didn't find a real solution in that one.

code concerning the QmlApplicationViewer in main.cpp:

QScopedPointer<QmlApplicationViewer> tQmlApplicationViewer(QmlApplicationViewer::create());
tQmlApplicationViewer->setResizeMode(QDeclarativeView::SizeRootObjectToView);

// Load the QML entrypoint
tQmlApplicationViewer->setMainQmlFile(QLatin1String("qml/BeTrains/main.qml"));

tQmlApplicationViewer->showFullScreen();

The code in main.qml

import QtQuick 1.1
import com.nokia.symbian 1.1
import com.nokia.extras 1.1
import "pages"
import "components"
import "js/utils.js" as Utils
import "js/storage.js" as Storage
import QtQuick 1.0

Window{
    id: window


    property string __schemaIdentification: "2"

    Component.onCompleted: {
        Storage.initialize()
    }

    //
    // Window structure
    //

    PageStackWindow {
        id: pagestackwindow1
        initialPage: mainPage
        showStatusBar: true
        showToolBar: true


        onRotationChanged: console.log("rotated!")
        Page {
            id: mainPage
           // orientationLock: PageOrientation.LockPortrait
            tools: toolBarLayout

             TabGroup {
                id: tabGroup
                currentTab: liveboardStack
                anchors.fill: parent

                PageStack {
                    id: liveboardStack
                    Component.onCompleted: liveboardStack.push(liveboardPage)
                }

                PageStack {
                    id: travelStack
                    Component.onCompleted: travelStack.push(travelPage)
                }


             }
        }

    }


    //
    // Toolbar
    //

    ToolBarLayout {
        id: toolBarLayout

        // Back buton
        ToolButton {
            property bool closeButton: tabGroup.currentTab.depth <= 1
            flat: true
            iconSource: closeButton ? "icons/close.svg" : "toolbar-back"
            onClicked: closeButton ? Qt.quit() : tabGroup.currentTab.pop();
        }

        // Tab bar

        ButtonRow {
            TabButton { id: tabBtnLiveboard; tab: liveboardStack; iconSource: "toolbar-list" }
            TabButton {id:tabBtnTravel;tab: travelStack; iconSource: "toolbar-search" }
        }

        // Menu
        ToolButton {
            iconSource: "toolbar-menu"
            onClicked: {
                if (!window.menu)
                    window.menu = Utils.loadObjectByComponent(menuComponent, window)
                window.menu.open()
            }
        }

    }


    //
    // Objects
    //

    // Statically loaded objects
    property variant liveboardPage: LiveboardPage {}
    property variant travelPage: TravelPage {}

    // Dynamically loaded objects
    property variant aboutDialog

    // In-line defined menu component
    property variant menu
    Component {
        id: menuComponent

        Menu {
            id: menu
            content: MenuLayout {
                // About
                MenuItem {
                    text: qsTr("About")
                    onClicked: {
                        if (!aboutDialog)
                            aboutDialog = Utils.loadObjectByPath("components/AboutDialog.qml", menu)
                        aboutDialog.open()
                    }
                }

                // Quit
                MenuItem {
                    text: qsTr("Quit")
                    onClicked: Qt.quit()
                }
            }
        }
    }

    Text {
        id: statustext
        x: 2
        y: 2
        width: 230
        height: 22
        color: "#ffffff"
        text: qsTr("BeTrains")
        font.pixelSize: 20
    }
}

The last text object was for testing purposes, and it rotated as it should... Image that shows the problem:

(I can't embed the image, so here's the link: http://i.stack.imgur.com/LXsxe.jpg )

The simulator result is on the left side, screenshots from my E7 on the right. The problem is circled in red.

Was it helpful?

Solution

Not sure what is the cause but your main.qml is weird... PageStackWindow is already a Window, why you wrap it with another Window? Try to remove the Window and use PageStackWindow as top level in main.qm

(Answer as commented by @Dickson)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top