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. TabView dynamically creating tabs, cant pass the data
Qt 6.11 is out! See what's new in the release blog

TabView dynamically creating tabs, cant pass the data

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 1.2k 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.
  • K Offline
    K Offline
    kolegs
    wrote on last edited by
    #1

    Hi,

    I got a problem with dynamically creating tabs in tabview. It works perfectlly for tab at index 0 but it wont work for rest. I create tabs when property actions changes and it creates tabs just fine but won't pass data.

    There is my code:
    @import QtQuick 2.0
    import QtQuick.Controls 1.1
    import QtQuick.Controls.Styles 1.1

    Rectangle {
    id: main
    property string inputName:"TEST-TEST-123"
    property string actions: ""
    property int tabCount: 0
    x:0
    y:0
    z:parent?parent.z+5: 0
    width: parent? parent.width : 0
    height: parent? parent.height : 0
    color: "green"
    // var componentttt
    onActionsChanged: {
    var test
    test=Qt.createComponent("qrc:/qml/actionsTab.qml")
    table.addTab("Tab "+table.count,test)
    while(test.status != Component.Ready)
    {
    console.log("NOT READY "+tabCount)
    }
    console.log("READY "+tabCount+" "+table.count+" "+test+" "+actions)
    table.getTab(tabCount).item.action=actions
    tabCount++
    }

    MouseArea{
        width:parent.width
        height: parent.height
        onClicked: {
            delete main
        }
    }
    Label{
        id: input
        x:0
        y:0
        text: inputName
    }
    TabView{
        id: table
        width:parent.width
        height: parent.height-input.contentHeight
        x:0
        y:input.contentHeight
        style: TabViewStyle{
            frameOverlap: 1
            tab: Rectangle{
                id: tabRec
                color: "steelblue"
                border.color: "white"
                implicitWidth: (main.width-implicitHeight) / table.count
                implicitHeight:  main.height/15
                radius: 2
                Text{
                    id: text
                    anchors.centerIn: parent
                    text: styleData.title
                    color: "white"
                }
            }
            frame: Rectangle{color: "black"}
        }
        onCurrentIndexChanged: {
            console.log("CURRENT TAB CHANGED "+currentIndex)
        }
    
    }
    

    }@

    Also, there is a code from console:
    @READY 0 1 QQmlComponent(0x20a5d170) DATA 1
    READY 0 2 QQmlComponent(0x1f5ea6a0) DATA 2
    qrc:/qml/actionsConfig.qml:27: TypeError: Type error
    READY 0 3 QQmlComponent(0x23493bf0) DATA 3
    qrc:/qml/actionsConfig.qml:27: TypeError: Type error@

    There is the code from actionsTab.qml
    @import QtQuick 2.0

    Rectangle {
    width: parent.width
    height: parent.height
    color: "black"
    property string action: ""
    Text{
    x:100
    y:100
    color: "white"
    text: action
    }
    }@

    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