Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

Launch a child QML window from a parent QML window

$
0
0
I am using Qt 5.1 and the Qt Quick Controls provided with it inorder to implement the user interface. I want to launch a (child) window when user clicks on a button. The part where I am confused is how I do it. Here is my code: import QtQuick 2.1 import QtWebKit 3.0 import QtQuick.Controls 1.0 import QtQuick.Layouts 1.0   ApplicationWindow {     title: "Facebook Authorizer"     width: 300     height: 300       ColumnLayout {         id: mainLayout         anchors.fill: parent           Button {             id: authorizationLauncher             text: "Authorize Facebook Account"             Layout.fillWidth: true               onClicked: {                 var component = Qt.createComponent("authorization-browser.qml");                 var browserWindow = component.createObject(this);             }         }     } } As shown above, I tried to use Qt.createComponent to load a qml file, and launch a window by creating its instance. It didn’t work. I tried to follow this link. [qt-project.org] The article pointed by the link also states that “Objects can also be created and managed from C++, and this is the preferred method for hybrid QML/C++ applications.”. My application, indeed, will contain a hybrid code. So, I thought this could be a better way. I did some reading on how to implement this, however, sadly failed to understand the implementation. Could anyone try and explain the process using this example – When user presses a button in the main QML window, another QML windows should launch. Some abstract explanation and links to articles that demonstrate this using Qt5+ would be welcome, too.

Viewing all articles
Browse latest Browse all 4972

Latest Images

Trending Articles



Latest Images