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. Howto expose ID of an element in an item ?
Forum Updated to NodeBB v4.3 + New Features

Howto expose ID of an element in an item ?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 3 Posters 326 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.
  • P Offline
    P Offline
    pingal
    wrote on last edited by
    #1

    I want to access the getText() function of TextField element, for that i'm trying to expose txtField, but it doesn't work

    Item {
        id: root
        property alias upload_dialog: upload_dialog
        property alias txtField: upload_dialog.col.txtField // This doesn't work
    
        Dialog {
            id: upload_dialog
            .
    
            Column {
                id: col
                anchors.fill: parent
                Text {
                    text: "Name"
                    .
                    .
                }
                TextField {
                    id: txtField
                    .
                    .
                }
            }
        }
    }
    
    J.HilkJ 1 Reply Last reply
    0
    • fcarneyF Offline
      fcarneyF Offline
      fcarney
      wrote on last edited by fcarney
      #2

      @pingal said in Howto expose ID of an element in an item ?:

      property alias txtField: upload_dialog.col.txtField

      It is not a hierarchy. Do this instead:

      property alias upload_dialog_txtField: txtField // or some other naming that suites you
      

      Edit: Also, for items loaded by loaders or in components you cannot alias to them like that. As far as I can tell you are not doing that.

      C++ is a perfectly valid school of magic.

      1 Reply Last reply
      0
      • P pingal

        I want to access the getText() function of TextField element, for that i'm trying to expose txtField, but it doesn't work

        Item {
            id: root
            property alias upload_dialog: upload_dialog
            property alias txtField: upload_dialog.col.txtField // This doesn't work
        
            Dialog {
                id: upload_dialog
                .
        
                Column {
                    id: col
                    anchors.fill: parent
                    Text {
                        text: "Name"
                        .
                        .
                    }
                    TextField {
                        id: txtField
                        .
                        .
                    }
                }
            }
        }
        
        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by
        #3

        @pingal I have the feeling I answered this recently....
        ah right:

        https://forum.qt.io/topic/133544/hot-to-reference-to-the-bordercolor


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        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