[Solved] Dynamically populate Qml TabView .
-
I'm trying to dynamically create tabs in Qml. This is my simple example of what I'm trying to do, but the code does not work. Well..sort of doesn't work. It creates the first tab correctly, but throws:
@ mainWindow.qml:20: TypeError: Cannot set property 'color' of null. @ .It seems I'm missing something in adding Tabs. What is wrong?
@import QtQuick 2.0
import QtQuick.Controls 1.0ApplicationWindow{
id:win
TabView{
id:tb
Component{
id:viewComp
Rectangle{
anchors.fill:parent
color:"black"
}
}
anchors.fill:parent
function loadTab(){
var t=addTab("x",viewComp)
t.item.color="blue" //line 20
}
MouseArea{
anchors.fill:parent
onClicked:tb.loadTab()
}
}}@
-
Sorry to reactivate this topic. What was the fix to the above problem? How can you force to component to be created? Thank you very much!
-
Alright...thank you very much!