Details
-
Bug
-
Resolution: Duplicate
-
P2: Important
-
None
-
5.13, 6.3
-
None
Description
the documents says like below:
https://doc.qt.io/qt-5/qtquickcontrols2-customize.html#customizing-combobox
// code placeholder popup: Popup { y: control.height - 1 width: control.width implicitHeight: contentItem.implicitHeight padding: 1 contentItem: ListView { clip: true implicitHeight: contentHeight model: control.popup.visible ? control.delegateModel : null currentIndex: control.highlightedIndex ScrollIndicator.vertical: ScrollIndicator { } } background: Rectangle { border.color: "#21be2b" radius: 2 } }
But when I try to print the delegateModel by JSON.stringfy, the app crashs.
// code placeholder import QtQuick 2.15 import QtQuick.Window 2.15 import QtQuick.Controls 2.12 Window { width: 640 height: 480 visible: true title: qsTr("Hello World") ComboBox { id: control model: ["First", "Second", "Third"] delegate: ItemDelegate { width: control.width contentItem: Text { text: modelData color: "red" font: control.font elide: Text.ElideRight verticalAlignment: Text.AlignVCenter } highlighted: control.highlightedIndex === index } contentItem: Text { leftPadding: 0 rightPadding: control.indicator.width + control.spacing text: control.displayText font: control.font color: control.pressed ? "#black" : "#red" verticalAlignment: Text.AlignVCenter elide: Text.ElideRight } background: Rectangle { implicitWidth: 120 implicitHeight: 50 border.color: control.pressed ? "#blue" : "#blue" border.width: control.visualFocus ? 2 : 1 radius: 2 } popup: Popup { y: control.height - 1 width: control.width implicitHeight: contentItem.implicitHeight padding: 1 contentItem: ListView { clip: true implicitHeight: contentHeight model: control.delegateModel currentIndex: control.highlightedIndex ScrollIndicator.vertical: ScrollIndicator { } } background: Rectangle { border.color: "#21be2b" radius: 2 } } } Button{ x:200 width: 100 height: 40 onClicked: { console.log(JSON.stringify(control.delegateModel)) } } }
Attachments
Issue Links
- duplicates
-
QTBUG-92192 Issues calling JSON.stringify() on objects
-
- Closed
-