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. Two QmlApplicationViewers in an application
Forum Updated to NodeBB v4.3 + New Features

Two QmlApplicationViewers in an application

Scheduled Pinned Locked Moved QML and Qt Quick
11 Posts 4 Posters 4.6k 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.
  • H Offline
    H Offline
    huluyige
    wrote on last edited by
    #1

    Hi everyone,

    I want to lock screen orientation on Portrait for some qml pages and lock it on Landscape for another qml pages. I didn't find a way to do it in QML.

    So here is my solution:

    I create 2 QmlApplicationViewers in the main.cpp, one is locked on Portrait and the other is locked on Landscape:

    @QmlApplicationViewer view1;
    view1.setOrientation(QmlApplicationViewer::ScreenOrientationLockPortrait);
    view1.showFullScreen();

    QmlApplicationViewer view2;
    view2.setOrientation(QmlApplicationViewer::ScreenOrientationLockLandscape);
    view2.close();@

    I also got some signals and slots to swith between those viewers. I thought this method should work. But a problem appears:

    the application is just take the view2's orientation into account. the two views seem to use the same orientation setting.

    My question is: how to solve this problem or anyone has other ideas to lock orientation for specific QML pages?

    Thanks

    1 Reply Last reply
    0
    • H Offline
      H Offline
      huluyige
      wrote on last edited by
      #2

      is it possible to set screen orientation on the fly?

      1 Reply Last reply
      0
      • M Offline
        M Offline
        minimoog77
        wrote on last edited by
        #3

        Why don't just read the accelerometers by yourself?

        1 Reply Last reply
        0
        • H Offline
          H Offline
          huluyige
          wrote on last edited by
          #4

          @minimoog77, thanks for your suggestion, But i didn't find a way to lock screen orientation using accelerometers, could you please explain it more?

          1 Reply Last reply
          0
          • M Offline
            M Offline
            minimoog77
            wrote on last edited by
            #5

            You will lock the orientation. Then you will use accelerometers to detect if it's orientation was changed, and you will manually orient the qml elements.

            But, why do you want locking the orientation both ways?

            1 Reply Last reply
            0
            • H Offline
              H Offline
              huluyige
              wrote on last edited by
              #6

              @minimoog77, i want to do it because, in my appli, there is a video player, i have to set it on Landscape, and for other QML pages, i want to locked it on portrait.

              you mean for the QmlApplicationViewer, l locke the application on portrait, and use accelerometers or orientation sensor to set orientation for video page?

              1 Reply Last reply
              0
              • M Offline
                M Offline
                minimoog77
                wrote on last edited by
                #7

                Yes, that was the idea, if you want full control of orientation.

                1 Reply Last reply
                0
                • H Offline
                  H Offline
                  huluyige
                  wrote on last edited by
                  #8

                  @minimoog77 ,but i can imagine, if i lock the application on portrait, all pages are locked on portait. Video page is included, i can use sensors to get orientation's changing signals to change qml elements' properties (width, height...etc), but i can't set orientation on Landscape. isn't it ?

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    minimoog77
                    wrote on last edited by
                    #9

                    You can rotate video page according to sensors.

                    1 Reply Last reply
                    0
                    • R Offline
                      R Offline
                      rishygupta
                      wrote on last edited by
                      #10

                      is it possible QmlApplicationViewer can be used or manipulated in other class rather than main;

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        mlong
                        wrote on last edited by
                        #11

                        rishygupta, you have asked this question in a number of threads, a couple of which are very old. Please open a separate thread for a new question and please don't duplicate your questions. Thanks.

                        Software Engineer
                        My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

                        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