Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Accessing QML TabView's Component properties "from the outside"



  • Hi,

    I have a TabView with a simple TextArea:

    import QtQuick 2.0
    import QtQuick.Controls 1.1
    
    Rectangle
    {
      TabView
      {
        id: tabs
    
        Component.onCompleted:
        {
          addTab("tab1", comp1)
        }
     }
    
      Component
      {
        id: comp1
    
        TextArea
        {
          id: textArea
          text: "Component 1"
        }
      }
    }
    

    The result is as expected:
    http://imageshack.com/a/img21/2066/e3ey.png(Tab)

    Now, I want to access tab elements from the outside. using a property alias. I tried the following without success:

    import QtQuick 2.0
    import QtQuick.Controls 1.1
    
    Rectangle
    {
      property alias comp1Text: tabs.getTab(0).textArea // <<==
    
      TabView
      {
        id: tabs
    
        Component.onCompleted:
        {
          addTab("tab1", comp1)
        }
    

    }

      Component
      {
        id: comp1
    
        TextArea
        {
          id: textArea
          text: "Component 1"
        }
      }
    }
    

    For the moment, I get the following error:
    Invalid alias reference. An alias reference must be specified as <id>, <id>.<property> or <id>.<value property>.<property>
    property alias comp1Text: tabs.getTab(0).textArea // <<==@

    So how can I access items that are enclosed into a TabView?

    Thanks a lot for any help.



  • Anybody? Using TabView in QML seems something basic to me.

    Best regards.


Log in to reply