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 properties into Components
Forum Updated to NodeBB v4.3 + New Features

passing properties into Components

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 2 Posters 211 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.
  • mzimmersM Offline
    mzimmersM Offline
    mzimmers
    wrote on last edited by mzimmers
    #1

    Hi all -

    I'm trying to pass information into a component:

    import QtQuick
    import QtQuick.Controls
    import QtQuick.Layouts
    
    Window {
        width: 640
        height: 480
        visible: true
        title: qsTr("Hello World")
    
        RowLayout {
            id: rowLayout
            anchors.fill: parent
            Loader {
                sourceComponent: component
                property string order: "first"
            }
            Loader {
                sourceComponent: component
                property string order: "second"
            }
        }
        Component {
            id: component
            Pane {
                id: innerPane
                height: 100; width: 100
                property string order
                Label {
                    text: innerPane.order
                }
            }
        }
    }
    

    It builds and runs without error, but no text displays.
    Is there a way to do this?

    Thanks...

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Bob64
      wrote on last edited by Bob64
      #2

      I think the issue is that you expect to be using the order property you have defined in your Loader but you have also declared an uninitialised order property in your Component which will hide the order defined in the Loader. If you didn't have the order property in your Component, you would simply be able to refer to order (not innerPane.order) as it would be inherited from the context provided by Loader.

      1 Reply Last reply
      3
      • mzimmersM mzimmers has marked this topic as solved on

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved