Simpler alternative, just a Repeater with a ListModel inside TabBar :
import QtQuick 2.0
import QtQuick.Window 2.2
import QtQuick.Controls 2.0
ApplicationWindow {
visible: true
width: 640
height: 480
ListModel {
id: tabModel
}
TabBar
{
Repeater {
model: tabModel
TabButton {
text: model.text + " " + model.index
onClicked: tabModel.remove(model.index)
}
}
}
Button
{
anchors.centerIn: parent
text:"add"
onClicked: tabModel.append({text: "tab"});
}
}
EDIT: My bad, I didn't saw @LeLev first answer, it's very similar to mine. But I fell compelled to post it cause there's a lot of over complicated code in the following answers.