import QtQuick 2.7 import QtQuick.Controls 2.1 import QtQuick.Layouts 1.3 ApplicationWindow { visible: true width: 640 height: 530 title: qsTr("blachat") StackLayout { id: swipeView anchors.fill: parent currentIndex: channel_tabs.currentIndex IrcChannel { objectName: "channel-status" } } Component { id: tabButton TabButton { text: "TabButton" } } footer: TabBar { id: channel_tabs objectName: "channel_tabs" TabButton { text: "status" } function add_channel(channel) { var newTab = tabButton.createObject(channel_tabs, {"text": channel}) channel_tabs.insertItem(channel_tabs.count, newTab) var newChannel = Qt.createComponent("IrcChannel.qml").createObject(swipeView, {"objectName": "channel-"+channel}) channel_tabs.currentIndex = channel_tabs.count-1 for (var i = 0; i < newChannel.children.length; ++i) { if (newChannel.children[i].objectName === "input") { newChannel.children[i].focus = true } } } function remove_channel(channel) { for (var i = 0; i < channel_tabs.count; ++i) { if (channel_tabs.itemAt(i).text === channel) { channel_tabs.removeItem(i) } } for (var i = 0; i < swipeView.children.length; ++i) { if (swipeView.children[i].objectName === "channel-"+channel) { swipeView.children[i].destroy() } } } } }