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. Accessing TabView elements by id does not work
Forum Updated to NodeBB v4.3 + New Features

Accessing TabView elements by id does not work

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

    Hi,

    I want to set a model of a view from some java code. In this simplified example just by using a menu action. The code works, but when putting the view into a Tab I cannot access the view anymore.
    It shows the error: ReferenceError: myview is not defined
    (Using Qt5.3.1)

    Can sombody explain why and how to fix this?

    @
    import QtQuick 2.2
    import QtQuick.Controls 1.1
    import QtQuick.Window 2.0

    ApplicationWindow {
    title: qsTr("demo")
    width: 640
    height: 480
    property int rqid: 0

    menuBar: MenuBar {
        Menu {
            title: qsTr("File")
    
            MenuItem {
                text: qsTr("test")
                onTriggered: {
                    myview.model = 10;
                }
            }
    
            MenuItem {
                text: qsTr("Exit")
                onTriggered: Qt.quit();
            }
        }
    }
    
    /* this here works */
    /*TableView {
        id: myview
        anchors.fill: parent
        TableViewColumn{ role: "firstname"  ; title: "First Name" ; width: 100 }
        TableViewColumn{ role: "lastname" ; title: "Last Name" ; width: 200 }
    }*/
    
    /* this here does not */
    TabView {
        id: tabview
        anchors.fill: parent
        Tab {
            title: "Contact List"
            TableView {
                id: myview
                TableViewColumn{ role: "firstname"  ; title: "First Name" ; width: 100 }
                TableViewColumn{ role: "lastname" ; title: "Last Name" ; width: 200 }
            }
        }
    }
    

    }
    @

    1 Reply Last reply
    0
    • G Offline
      G Offline
      gergap
      wrote on last edited by
      #2

      I found a workaround by giving the tab an id and use
      @tabContacts.children[0].model = x.results;@

      Nevertheless it would be nice that ids work also for tab children.

      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