3

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.

4

1 回答 1

0

不知道是什么原因,但你的 main.qml 很奇怪...... PageStackWindow 已经是一个窗口,为什么你用另一个窗口包装它?尝试删除 Window 并将 PageStackWindow 用作 main.qm 中的顶层

(@Dickson 评论的答案)

于 2012-12-18T15:25:13.693 回答