Я пытаюсь динамически загружать вкладки в TabView из другого файла. Для этого я использую Qt.createComponent и добавляю компонент в представление. Вкладка загружена, но ее содержимое не отображается и загружено правильно. Нравится:
TabView {
id:editor
Layout.minimumWidth: 50
Layout.fillWidth: true
}
Component.onCompleted: {
function newTab() {
var c = Qt.createComponent("tab.qml");
editor.addTab("tab", c);
var last = editor.count - 1;
editor.getTab(last).active = true;
}
newTab();
newTab();
}
И файл tab.qml:
import QtQuick 2.0
import QtQuick.Layouts 1.1
import QtQuick.Controls 1.4
Tab {
Rectangle {
Layout.fillWidth: true
Layout.fillHeight: true
color: "lightgray"
TextArea {
anchors.fill: parent
}
}
}
Что я делаю не так?