open new window on button click
-
wrote on 12 Jan 2021, 16:00 last edited by
It's a really simple, maybe stupid question, but I've been looking for this all day without success.
I have a main window (main.qml) with a button. When this button is clicked I want to open a new window (window2.qml). I want to do this using the 'onClicked:' component, and found online, to open a window, I can use 'show()', but I have not been successful in combining these two.
I'm new to this, would love every answer :)
Thanks in advance.
-
Something like this should work:
Button { text: "Open window" onClicked: window2.show() } // You need to rename window2.qml to Window2.qml Window2 { id: window2 visible: false }
Or you can use Loader to defer loading of the second window's QML code.
-
wrote on 16 Jan 2021, 17:31 last edited by
//*** help button Button{ id: helpButton height: hButton text: qsTr("Help") onClicked:{ var component = Qt.createComponent("HelpForm.qml") var window = component.createObject() window.show() } }
I hope this can help you ....
1/3