Open new window

  • Hello,

    I have a simple (maybe stupid) question but I didn't find the information for QML controls2.

    I have a main window with a rectangle. When the user click on this rectangle, I want to open a second window on top of the main window (like a configuration window).

    My main file is:

    import QtQuick 2.7
    import QtQuick.Controls 2.0
    import QtQuick.Layouts 1.0
    ApplicationWindow {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
            width: 100
            height: 100

    The line "onClicked:open("newwin.qml")" should be replaced by the proper command.

    Thank you very much,


  • Hello again,

    I found this:

                    var component = Qt.createComponent("\Newwin2.qml");
                    win = component.createObject();

    It works, but I am not sure it is the right way to do it. The component is created but I am not sure if it is destroyed.
    Could you help me out ?

    Thank you very much,


Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.