我想添加一个tabButton到TabBar动态按下按钮,但我花了很多时间搜索,但我没有得到如何添加,下面是代码,我我工作的:动态添加TabButton到QML中的TabBar
MyTabButton.qml
import QtQuick 2.4
import QtQuick.Controls 2.2
Item
{
property int BtnWidth:0
property int BtnHeight:0
property string BtnText: ""
property bool isChecked : false
TabButton
{
id:tabBtn
text:BtnText
width:BtnWidth
height:BtnHeight
}
}
MainForm.qml
import QtQuick 2.4
import QtQuick.Controls 2.2
Rectangle
{
Button
{
id:button
width:100
height:100
anchors.top:parent.top
text:qStr("Add")
onClicked{
//How to add logic here to add tab in below tabBar.
}
}
TabBar
{
id:tabBar
anchors.top:button.bottom
width:500
height:500
}
}
这正是我所需要的,但如果我想使用一个函数在** MyTabButton中创建** say ** doSomething()**如何访问** tabBar中的onCurrentIndexChanged()事件处理函数? – pra7
你想调用所有'TabButtons'的'doSomething'或者只调用'doBometon'吗? – derM
我需要调用所有'TabButtons'的'doSomething',因为我正在对TabButton进行一些绘制...... – pra7