【问题标题】:Dynamically loaded QML-file in Tab will only be executed when Tab is shown选项卡中动态加载的 QML 文件仅在显示选项卡时执行
【发布时间】:2014-11-10 09:28:06
【问题描述】:

我正在通过 TabView 动态创建 Tabs

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

但是,在我点击Tab 之前,他们的代码并没有被执行。 我该如何解决这个问题?

【问题讨论】:

    标签: qt qml qtquick2 qt5.3 qtquickcontrols


    【解决方案1】:

    创建的Tab 继承自Loader,其active 属性设置为false,直到单击Tab。只需在创建 active 属性后显式设置它:

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

    【讨论】:

    • 完美运行。非常感谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-08-15
    • 1970-01-01
    • 1970-01-01
    • 2012-04-16
    • 2012-10-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多