I’m playing with QT to make a couple of apps for Nokia phone, here the first snippet: “How to lock the phone orientation”, in this case I will lock in Portrait position, even when the user rotate the phone, the screen won’t rotate

    viewer->setOrientation(QmlApplicationViewer::ScreenOrientationLockPortrait);

The complete code:

Q_DECL_EXPORT int main(int argc, char *argv[])
{
    QScopedPointer<QApplication> app(createApplication(argc, argv));
    QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create());

    viewer->setMainQmlFile(QLatin1String("qml/MyProject/main.qml"));
    viewer->showExpanded();
    viewer->setOrientation(QmlApplicationViewer::ScreenOrientationLockPortrait);

    return app->exec();
}

 

Leave a reply

 

Your email address will not be published.