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. [SOLVED] Reference error: id is not defined
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Reference error: id is not defined

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 15.7k 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
    pawelm
    wrote on last edited by
    #1

    After clicking row in table view I get this error:
    "ReferenceError: customID is not defined", despite of fact that I have element with this ID. What's wrong?

    Here is code (only that, what in my opinion is important in this case)

    @
    import QtQuick.Layouts 1.0
    import QtQuick 2.4
    import QtQuick.Controls 1.3
    import QtQuick.Window 2.2
    import QtQuick.Dialogs 1.2

    Rectangle
    {
    ListModel
    {
    id: usersModel
    }

    TabView 
    {
        Tab 
        {
            title: "1"
            RowLayout
            {
                ColumnLayout
                {
                    TableView
                    {
                        onClicked: customID.color = "#FFFFFF"
                        TableViewColumn
                        {
                        }
                    }
                }
                Rectangle 
                {
                    TabView
                    {
                        Tab
                        {
                            title: "A"
                            Rectangle
                            {
                                id: customID
                                color: "#00000000"
                            }
                        }
                    }
                }
            }
        }
    }
    

    }
    @

    Sorry for my English.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      David Stiel
      wrote on last edited by
      #2

      Hi

      customerId is within a Tab (which inherits from Loader), so it's not possible to use customerId to refere to the element from outside the Tab/Loader using customerId.

      You can look "here":http://doc.qt.io/qt-5/qml-qtquick-loader.html#receiving-signals-from-loaded-objects for one way of accessing "customID".

      I would probably create a property in the top TabView to propagate the information

      1 Reply Last reply
      1
      • P Offline
        P Offline
        pawelm
        wrote on last edited by
        #3

        Thank you very much! Now it works.

        Sorry for my English.

        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