Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Passing parameters between windows
Forum Updated to NodeBB v4.3 + New Features

Passing parameters between windows

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 2.6k Views 1 Watching
  • 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.
  • F Offline
    F Offline
    fermatqt
    wrote on last edited by
    #1

    hello everybody
    I'm new to the forum!

    I would like to know if is it possible to pass parameters between windows with qml.
    this event of the main window:
    @MouseArea {
    anchors.fill: parent
    onClicked: {
    Qt.createComponent("detail_dialog.qml").createObject(mainWindow, {});
    }
    }@

    and this is the detail_dialog.qml:

    @import QtQuick 2.0

    Item {
    Component.onCompleted: console.log(text)
    id: detailDialog
    anchors.fill: parent
    PropertyAnimation {
    target: detailDialog
    property: "opacity"
    duration: 400
    from: 0
    to: 1
    easing.type: Easing.InOutQuad
    running: true
    }
    Rectangle {
    id: dialogWindow
    width: 200
    height: 200
    radius: 10
    border.color: "black"
    anchors.centerIn: parent
    Text {
    anchors.centerIn: parent
    text: "Hello"
    }
    MouseArea{
    anchors.fill: parent
    onClicked: {
    detailDialog.destroy()
    }
    }
    }
    }
    @

    is it possible?

    1 Reply Last reply
    0
    • O Offline
      O Offline
      onek24
      wrote on last edited by
      #2

      Hello and welcome to devnet,

      i would go ahead and use signals for that. For example:

      • Creating the component: @var component = Qt.createComponent("detail_dialog.qml.qml");
        dialog = component.createObject(root);
        dialog.show();@
      • Creating the signals in your detail_dialog.qml, for example: signal mySignal()
      • Accessing the signals with for example: dialog.onMySignal()
        Havn't tested it out yet but it should theoretically work,
      1 Reply Last reply
      0
      • F Offline
        F Offline
        fermatqt
        wrote on last edited by
        #3

        ok I solved without knowing it.
        the data is from this javascript function.
        in the dialog was enough for me to do so:

        @
        Text {
        anchors.centerIn: parent
        text: "AUTORE: " + author + "\n" + "EDITORE: " + editor
        }
        @

        this is the javascript function, and is called in the main.qml

        @
        function load() {
        listModelJson.clear();
        var xhr = new XMLHttpRequest();
        xhr.open("GET","http://www.sito.com/file.php", true);
        xhr.onreadystatechange = function() {
        if (xhr.readyState == xhr.DONE) {
        if (xhr.status == 200) {
        var jsonObject = JSON.parse(xhr.responseText);
        for (var i in jsonObject) {
        listModelJson.append({
        "title" : jsonObject[i].title,
        "author" : jsonObject[i].author,
        "editor" : jsonObject[i].editor
        });
        }
        }
        }
        }
        xhr.send();
        }
        @

        thanks!!

        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