チェック可能なボタンにExclusiveGroupを割り当てることができません。QML Button exclusiveGroupプロパティ?
ExclusiveGroup {
id: group
onCurrentChanged: {
if(current != null) {
console.info("button checked...no!")
current = null
//current.checked = false <--- also this
}
}
}
Column {
width: parent.width
spacing: 0
Button {
id: btnScan
flat: true
text: qsTr("But1")
width: parent.width
checkable: true
exclusiveGroup: group
}
Button {
id: btnWhiteList
flat: true
text: qsTr("But2")
width: parent.width
checkable: true
exclusiveGroup: group
}
}
文書には、exclusiveGroupプロパティhttp://doc.qt.io/qt-5/qml-qtquick-controls-button.html#exclusiveGroup-propが含まれていることが明確に記載されています。しかし、私は例を実行すると、私はこのエラーを取得:「無効なプロパティ名exclusiveGroup」:
qrc:/main.qml:48 Cannot assign to non-existent property "exclusiveGroup"
は「exclusiveGroup」の上にマウスを置くと、ツールチップが言って現れます。
Qt 5.9.1がインストールされています。ここに私のインポートステートメントがあります:
import QtQuick 2.7
import QtQuick.Controls 1.4
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
import QtQuick.Controls.Material 2.2
私は間違っていますか?
おかげ
は奇妙なのthats:
は、コントロールの両方のセットは読みの違いとユースケースの詳細について
QtQuick.Controls 2.x
のための同様の解決のために
ButtonGroup
を参照してください。 2.0で定義されたプロパティも必要な場合はどうすればよいですか?異なるバージョンで定義されたすべてのボタンプロパティを使用する方法はありませんか? – Davitaありがとう、ButtonGroupはトリックを行い、あなたの答えを受け入れました。しかし、私の混乱はまだバージョン管理に残っています。私が物事をクリアするのを助けることができたら、私はとても感謝しています:) – Davita