Hedge
Hedge

Reputation: 16748

Dynamically loaded QML-file in Tab will only be executed when Tab is shown

I'm creating Tabs in a TabView dynamically via

var component = Qt.createComponent("file://tabcontent.qml"));
tabView.addTab(component);

However their code is not executed before I click on the Tab itself. How can I solve this?

Upvotes: 1

Views: 725

Answers (1)

jturcotte
jturcotte

Reputation: 1273

The created Tab inherits from Loader with its active property set to false until the Tab is clicked. Just explicitly set the active property after creating it:

var component = Qt.createComponent("file://tabcontent.qml'));
var tab = tabView.addTab(component);
tab.active = true;

Upvotes: 4

Related Questions