【发布时间】:2020-03-02 23:14:46
【问题描述】:
【问题讨论】:
标签: qt tabs qml tabbar tabview
【问题讨论】:
标签: qt tabs qml tabbar tabview
您可以在 QML 的任何其他项目中嵌入任何内容。通过使用states,可以让 TabButton 在不同的状态下运行(呵呵),在本例中为"editing" 状态,其中某些部分仅在该状态下显示,而其他部分则被隐藏。
您应该将以下内容放在一些 qml 中
import QtQuick 2.0
import QtQuick.Controls 2.3
TabButton {
id: btn
onDoubleClicked: state = "editing"
TextField {
id: editor
anchors.fill: parent
text: btn.text
visible: false
onAccepted: {
btn.text = text
btn.state = ""
}
}
states: [
State {
name: "editing"
PropertyChanges {
target: editor
focus: true
visible: true
}
PropertyChanges {
target: btn
explicit: true
restoreEntryValues: false
text: "" //so the text won't show up during editing
}
}
]
}
【讨论】: