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. Is it possible to create an Item (qml) with its own Window?
Forum Updated to NodeBB v4.3 + New Features

Is it possible to create an Item (qml) with its own Window?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
11 Posts 5 Posters 1.6k Views 2 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
    mnesarco
    wrote on 3 Dec 2020, 13:54 last edited by
    #1

    Hi Friends,
    I want to create a QuickItem to embed some external content, but i need a Window. As far as I know, all the qml scene share the same window. In my case I need my own window but i need it to play well with layouts. I need someting like QtQuick.Window but embedded as a normal Item in the scene.

    Do you think it is possible?

    Thanks,
    Frank.

    B 1 Reply Last reply 3 Dec 2020, 15:06
    0
    • M mnesarco
      3 Dec 2020, 13:54

      Hi Friends,
      I want to create a QuickItem to embed some external content, but i need a Window. As far as I know, all the qml scene share the same window. In my case I need my own window but i need it to play well with layouts. I need someting like QtQuick.Window but embedded as a normal Item in the scene.

      Do you think it is possible?

      Thanks,
      Frank.

      B Offline
      B Offline
      Bob64
      wrote on 3 Dec 2020, 15:06 last edited by
      #2

      @mnesarco I might have misunderstood, but isn't Window what you need? You can use this to create a new top-level window, parented to your 'main' window.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mnesarco
        wrote on 3 Dec 2020, 15:52 last edited by
        #3

        The problem with Window is that it is no managed by the Layouts inside the parent window. It is an independent window.

        J 1 Reply Last reply 3 Dec 2020, 15:56
        0
        • M mnesarco
          3 Dec 2020, 15:52

          The problem with Window is that it is no managed by the Layouts inside the parent window. It is an independent window.

          J Offline
          J Offline
          J.Hilk
          Moderators
          wrote on 3 Dec 2020, 15:56 last edited by
          #4

          @mnesarco So what exactly do you want ?

          The look of a separated window, but fixed inside the layout of an other qml component ?


          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
          0
          • M Offline
            M Offline
            mnesarco
            wrote on 3 Dec 2020, 16:03 last edited by
            #5

            What I want is an Item that have its own native Window, but looks and behave like any other Item (ie like a Rectangle) so it can be layed out like any other component. Noboby needs to know that it is actually another window.

            I managed to do that creating an Item with a nested frameless window and connecting Item's x,y,width,height with the window. It works but I wonder if is there a better way.

            1 Reply Last reply
            0
            • F Offline
              F Offline
              fcarney
              wrote on 3 Dec 2020, 23:32 last edited by
              #6

              @mnesarco said in Is it possible to create an Item (qml) with its own Window?:

              Item that have its own native Window

              What is the driver behind this?

              C++ is a perfectly valid school of magic.

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mnesarco
                wrote on 4 Dec 2020, 02:06 last edited by
                #7

                I am using opengl backend.
                This is my current solution:

                // WindowItem.qml
                
                import QtQuick
                import QtQuick.Window
                import QtQuick.Controls
                
                Item {
                    id: root
                    default property alias data: wnd.data
                    property int globalX: { 
                        var p = parent;
                        var v = Window.window.x + x;        
                        while (p) {
                            if (p.x) {
                                v += p.x;
                            }
                            if (p.contentItem != null) {
                                v += p.contentItem.x;
                            }
                            p = p.parent;
                        }
                        return v;
                    }
                    property int globalY: { 
                        var p = parent;
                        var v = Window.window.y + y;        
                        while (p) {
                            if (p.y) {
                                v += p.y;
                            }
                            if (p.contentItem != null) {
                                v += p.contentItem.y;
                            }
                            p = p.parent;
                        }
                        return v;
                    }
                    property int flags: Qt.WindowStaysOnBottomHint
                    
                    Window {
                        id: wnd
                        flags: Qt.Tool | Qt.FramelessWindowHint | root.flags
                        x: root.globalX
                        y: root.globalY
                        width: root.width
                        height: root.height
                        visible: true
                    }
                }
                
                

                It can be used inside the scene and play well with layouts:

                Row {
                  Label {
                    ...
                  }
                  WindowItem {
                    ....
                  }
                }
                
                B 1 Reply Last reply 4 Dec 2020, 09:43
                0
                • M mnesarco
                  4 Dec 2020, 02:06

                  I am using opengl backend.
                  This is my current solution:

                  // WindowItem.qml
                  
                  import QtQuick
                  import QtQuick.Window
                  import QtQuick.Controls
                  
                  Item {
                      id: root
                      default property alias data: wnd.data
                      property int globalX: { 
                          var p = parent;
                          var v = Window.window.x + x;        
                          while (p) {
                              if (p.x) {
                                  v += p.x;
                              }
                              if (p.contentItem != null) {
                                  v += p.contentItem.x;
                              }
                              p = p.parent;
                          }
                          return v;
                      }
                      property int globalY: { 
                          var p = parent;
                          var v = Window.window.y + y;        
                          while (p) {
                              if (p.y) {
                                  v += p.y;
                              }
                              if (p.contentItem != null) {
                                  v += p.contentItem.y;
                              }
                              p = p.parent;
                          }
                          return v;
                      }
                      property int flags: Qt.WindowStaysOnBottomHint
                      
                      Window {
                          id: wnd
                          flags: Qt.Tool | Qt.FramelessWindowHint | root.flags
                          x: root.globalX
                          y: root.globalY
                          width: root.width
                          height: root.height
                          visible: true
                      }
                  }
                  
                  

                  It can be used inside the scene and play well with layouts:

                  Row {
                    Label {
                      ...
                    }
                    WindowItem {
                      ....
                    }
                  }
                  
                  B Offline
                  B Offline
                  Bob64
                  wrote on 4 Dec 2020, 09:43 last edited by
                  #8

                  @mnesarco it's kind of a secondary point but I wondered if you might be able to save some of that work you are doing with coordinate mapping by using the mapToItem function from Item?

                  On the main topic, did you consider using a custom QQuickItem to integrate your external content? I don't know how feasible it would be but there are hooks to insert your own scene graph content.

                  M 1 Reply Last reply 4 Dec 2020, 13:44
                  0
                  • B Bob64
                    4 Dec 2020, 09:43

                    @mnesarco it's kind of a secondary point but I wondered if you might be able to save some of that work you are doing with coordinate mapping by using the mapToItem function from Item?

                    On the main topic, did you consider using a custom QQuickItem to integrate your external content? I don't know how feasible it would be but there are hooks to insert your own scene graph content.

                    M Offline
                    M Offline
                    mnesarco
                    wrote on 4 Dec 2020, 13:44 last edited by
                    #9

                    @Bob64 I have used mapToGlobal with bad results, so I resorted to manual parent position calculation. I have to try mapToItem, the main problem is that those functions do not take into account the size of the Menubar in the window. And because the Window is a top level window, at the end, I need to add Window's position too.

                    I have my own QQuickItem in C++, the problem is that the external renderer (OpenCascade/opengl) uses the whole window and I cannot change that. So I need to provide a different window because if not it renders under the whole schene.

                    1 Reply Last reply
                    0
                    • L Offline
                      L Offline
                      Lucasvct
                      wrote on 28 Dec 2020, 15:44 last edited by
                      #10

                      Hi @mnesarco, I have the same problem. Did you find a solution ?

                      M 1 Reply Last reply 29 Dec 2020, 03:15
                      0
                      • L Lucasvct
                        28 Dec 2020, 15:44

                        Hi @mnesarco, I have the same problem. Did you find a solution ?

                        M Offline
                        M Offline
                        mnesarco
                        wrote on 29 Dec 2020, 03:15 last edited by
                        #11

                        @Lucasvct I have posted my current solution in this thread. have you tryed it?

                        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