[SOLVED] Reference error: id is not defined



  • 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"
                            }
                        }
                    }
                }
            }
        }
    }
    

    }
    @



  • 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



  • Thank you very much! Now it works.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.