TabView dynamically creating tabs, cant pass the data
-
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.1Rectangle {
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.0Rectangle {
width: parent.width
height: parent.height
color: "black"
property string action: ""
Text{
x:100
y:100
color: "white"
text: action
}
}@