Important: Please read the Qt Code of Conduct -

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

  • 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?


  • @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.

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

  • Moderators

    @mnesarco So what exactly do you want ?

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

  • 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.

  • @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?

  • 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:
        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 {

  • @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.

  • @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.

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

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

Log in to reply