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. How to pass properties to a child window
Forum Updated to NodeBB v4.3 + New Features

How to pass properties to a child window

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 1.3k 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.
  • G Offline
    G Offline
    g1ennr
    wrote on last edited by
    #1

    Hi,

    I have a dialog that I am showing using QQuickView (PyQt5). Before loading the QML I set a userName property using view.rootContext().SetContextProperty(). In the main form the userName I set is displayed correctly, but when I open a child form (using the QML Window class) and attempt to pass the userName to it then it gets set to the default value instead of the value that I set in SetContextProperty.

    What is going wrong here and how can I fix it?

    Glenn

    @
    Rectangle {
    id: main
    objectName: "main"
    property string userName: "Foo Bar"
    ...
    MouseArea {
    ...
    onClicked: {
    editNameForm.visible = true
    editNameForm.userName = "%1".arg(main.userName)
    // main.userName Is always "Foo Bar" instead of the value set using SetContextProperty()
    console.log("userName: ", main.userName)
    }
    }
    EditName {
    // This is derived from the Window class
    id: editNameForm
    ....
    }
    }
    @

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      What if you don't assign the "Foo Bar" to userName ? Just keep it like this,

      @ property string userName@

      157

      1 Reply Last reply
      0
      • G Offline
        G Offline
        g1ennr
        wrote on last edited by
        #3

        Look's like the forum lost a few posts.

        [quote author="p3c0" date="1382158485"]Hi,

        What if you don't assign the "Foo Bar" to userName ? Just keep it like this,

        @ property string userName@[/quote]

        If I do that that then it still passes through the initial value of userName, which in this case is "".

        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