Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Open new window

Open new window

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 1 Posters 785 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.
  • A Offline
    A Offline
    alecs26
    wrote on last edited by
    #1

    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")
    
        Rectangle
        {
            width: 100
            height: 100
            color:"#000000"
            MouseArea
            {
                anchors.fill:parent
                onClicked:open("newwin.qml")
            }
        }
    }
    

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

    Thank you very much,

    Alex

    1 Reply Last reply
    0
    • A Offline
      A Offline
      alecs26
      wrote on last edited by
      #2

      Hello again,

      I found this:

                  onClicked:
                  {
                      var component = Qt.createComponent("\Newwin2.qml");
                      win = component.createObject();
                      win.show();
                  }
      

      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,

      Alex

      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