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. Z-Order globally

Z-Order globally

Scheduled Pinned Locked Moved Solved QML and Qt Quick
9 Posts 3 Posters 773 Views
  • 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.
  • K Offline
    K Offline
    krowa
    wrote on last edited by
    #1

    Hi,
    how i can use z-globally ?
    (z-order work only on siblings ....how i have read)

    heir is a simple sample (https://saengjja.tistory.com/176) (ok on china-language but code is clear )
    how I can override here "yellow"-rectangle ?

    What is this solution for this problem ?
    thanks a lot !!!
    Marian

    J.HilkJ 1 Reply Last reply
    0
    • fcarneyF Offline
      fcarneyF Offline
      fcarney
      wrote on last edited by
      #2
      Rectangle {
        color: "yellow"
      }
      Rectangle {
        color: "red"
        Rectangle {
          color: "blue"
        }
      }
      

      If you want yellow behind the other rectangles then declare it before the other rectangles.

      C++ is a perfectly valid school of magic.

      1 Reply Last reply
      0
      • K Offline
        K Offline
        krowa
        wrote on last edited by
        #3

        Hi fcarney,
        yes but this is not really solution !
        This only simple example ....
        In my app I have much row-list-views with much Items, (all dynamically load), If I move a Item that need always on top ..... need undepend from load order !!!

        1 Reply Last reply
        0
        • fcarneyF Offline
          fcarneyF Offline
          fcarney
          wrote on last edited by
          #4

          If your Items are model driven then change the order of the items in the model.

          You might be better served to create a minimal example that represents what you are actually doing than a contrived simplistic version.

          I will often create a side project that accurately reflects what I am doing and recreates the problem. Code is cut and pasted from larger projects in order to keep the example as accurate as possible. This takes time, but it will save you time when asking for help.

          C++ is a perfectly valid school of magic.

          1 Reply Last reply
          0
          • K krowa

            Hi,
            how i can use z-globally ?
            (z-order work only on siblings ....how i have read)

            heir is a simple sample (https://saengjja.tistory.com/176) (ok on china-language but code is clear )
            how I can override here "yellow"-rectangle ?

            What is this solution for this problem ?
            thanks a lot !!!
            Marian

            J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on last edited by J.Hilk
            #5

            @krowa
            ok, here's a hack for your problem:

            • Create a c++ class either as root context property or as a singleton.
            • Give it a Q_PROPERTY of QObject *
            • at the top most level inside main.qml assign the root element to that c++ QObject -Pointer
            • where you need it / want a top level/ top z-order, use this object pointer for the parent property of the QML Item

            I use this for a custom Popup component, in an application where the root component is neither a Window or Application Window.

            It works, but it will make your skin crawl :D


            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            1 Reply Last reply
            1
            • fcarneyF Offline
              fcarneyF Offline
              fcarney
              wrote on last edited by
              #6

              You just gave me an idea. I don't read chinese so I cannot tell what they are trying to accomplish. But qml has a way to use states to change parenting of an object. This could be used to reparent an object to do what you said. So the selected item could reparent itself as a popup.

              C++ is a perfectly valid school of magic.

              1 Reply Last reply
              0
              • K Offline
                K Offline
                krowa
                wrote on last edited by
                #7

                I thought and hoped that this was a totally trivial problem and I just overlooked something ...

                look like this no standart solution....

                • what is this technical problem ?
                • what is solution of this problem ?

                @fcarney
                I thinking this example describe and show my understanding problem.
                I was very surprised that it doesn't work as I think.....

                @J.Hilk
                ok, is but this is a hack , I will read you code tomorow again and have sure question :-)

                for my understanding, I sure could if I move a item, first remove/delete this item and after add again ......but this not really solution, very dirty hack .......

                Marian

                fcarneyF 1 Reply Last reply
                0
                • K krowa

                  I thought and hoped that this was a totally trivial problem and I just overlooked something ...

                  look like this no standart solution....

                  • what is this technical problem ?
                  • what is solution of this problem ?

                  @fcarney
                  I thinking this example describe and show my understanding problem.
                  I was very surprised that it doesn't work as I think.....

                  @J.Hilk
                  ok, is but this is a hack , I will read you code tomorow again and have sure question :-)

                  for my understanding, I sure could if I move a item, first remove/delete this item and after add again ......but this not really solution, very dirty hack .......

                  Marian

                  fcarneyF Offline
                  fcarneyF Offline
                  fcarney
                  wrote on last edited by
                  #8

                  @krowa A state can temporarily change the parenting of an object. When the state clears it is reset.

                  ParentChange

                  This could be used to temporarily move the object to a different parent with a higher z order priority.

                  C++ is a perfectly valid school of magic.

                  1 Reply Last reply
                  1
                  • K Offline
                    K Offline
                    krowa
                    wrote on last edited by krowa
                    #9

                    Hi
                    I have change parent if I moving the item to root element and it WORKS!
                    thanks a lot J.Hilk, fcarney
                    Marian

                    1 Reply Last reply
                    2

                    • Login

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