Qml orientation animation



  • hi there,

    i started working with qml and got a problem.
    i like to animate my ui when the sreenorientation changes. but without black screen.
    i have googled a lot, but i can't get it working.

    i tried to do it like the first comment on "this ":http://www.developer.nokia.com/Community/Wiki/Implementing_orientation_change_animation_with_QML site says.
    But i cant get it working because the connect is not possible with my qmlapplicationviewer.
    How can i connect a signal of my qmlapplicationviewer to a function in my main.qml?

    Thanks in advance!

    my main.cpp:

    @QScopedPointer<QApplication> app(createApplication(argc, argv));
    QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create());
    viewer->setMainQmlFile(QLatin1String("qml/Tankinatornew/main.qml"));
    viewer->setOrientation(viewer->ScreenOrientationLockPortrait);
    viewer->showExpanded();@



  • ok, i was able to connect the signal to a function.
    but now i have another problem.
    i created a new class inheriting QDeclarativeView. This class should send a signal when its resizeEvent() is called. but that never happens without showing it. But when i show it i can't see my viewer, so there is an empty screen. i also tried to set its stylesheet transparent, but then the screen is white.
    How can i show "viewer" and let "my" run the resizeEvent on switching the phone?

    my code:
    @
    QScopedPointer<QApplication> app(createApplication(argc, argv));
    QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create());
    viewer->setMainQmlFile(QLatin1String("qml/Tankinatornew/main.qml"));
    viewer->setOrientation(viewer->ScreenOrientationLockPortrait);
    viewer->showExpanded();
    MyClass my;
    //my.showFullScreen();
    QObject rootObject = dynamic_cast<QObject>(viewer->getrootObject());
    QObject::connect(&my, SIGNAL(data(QVariant)), rootObject, SLOT(updateori(QVariant)));

    return app->exec&#40;&#41;;@

  • Moderators

    I don't want to get into your code too much, but I can tell you how I did it. A simple, yet powerful solution, totally OS independent.

    In my main QML file, I set height and width by reading a property from C++. This property is being updated by a slot that is connected to QWidget::resize() (in this case, that would be QDeclarativeView::resize()).

    Also, you'll need to set this: viewer->setResizeMode(QDeclarativeView::SizeRootObjectToView);


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.