Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Qml orientation animation
Qt 6.11 is out! See what's new in the release blog

Qml orientation animation

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 2.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Matze5590
    wrote on last edited by
    #1

    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();@

    1 Reply Last reply
    0
    • M Offline
      M Offline
      Matze5590
      wrote on last edited by
      #2

      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;;@
      
      1 Reply Last reply
      0
      • sierdzioS Offline
        sierdzioS Offline
        sierdzio
        Moderators
        wrote on last edited by
        #3

        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);

        (Z(:^

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved