Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Child Windows are always under the main window

    QML and Qt Quick
    2
    4
    1200
    Loading More Posts
    • 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
      maksim1979 last edited by

      Hey hey

      When I create new standalone windows from QML, using code like this
      @
      var component = Qt.createComponent("Window.qml");
      var win = component.createObject(root);
      win.show();
      @

      the created windows are always on top of the main window, but child windows itself behave correctly. I wonder what I'm doing wrong :)

      1 Reply Last reply Reply Quote 0
      • M
        maksim1979 last edited by

        I've just noticed, that windows are created this way not "true" windows, in that sence OS Windows taskbar doesn't have it (I mean there is only on task for main window). So apparently I have to launch new window from C++ code, like this
        @
        QtQuick2ApplicationViewer viewer2;
        viewer2.setMainQmlFile(QStringLiteral("path/to/qml"));
        viewer2.showExpanded();
        @

        Is it correct (espessially from performance point of view)?

        1 Reply Last reply Reply Quote 0
        • dheerendra
          dheerendra Qt Champions 2022 last edited by

          What is your objective. Both are right code. Do you want to launch seperate window ? If that is the case, you should use the second code piece.

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          1 Reply Last reply Reply Quote 0
          • M
            maksim1979 last edited by

            Dheerendra, I'm trying to implement something similar to Chrome tabs. I mean user should be able to move tab into another new/existing window.
            The approach with QtQuick2ApplicationViewer is ok for me, but i don't understand how to pass some qml objects to a new window that I would like to move. Btw, I just found why I didn't have tasks for each window in OS taskbar. It's due to this line
            @
            var win = component.createObject(root);
            @

            Root is not needed,
            @
            var win = component.createObject();
            @

            gives me what I need

            1 Reply Last reply Reply Quote 0
            • First post
              Last post