Issue using combobox on Listview
Solved
QML and Qt Quick
-
Hello,
I do experience an issue where I'm trying to implement a list of option of different type.
I do have an option that use a combobox and this specific type of option does make the app crash.
The error I have is :EGLFS: OpenGL windows cannot be mixed with others.
Here is the code I'm trying implement :
The combobox option component :
import QtQuick 2.0 import QtQuick.Controls 1.3 import QtQuick.Layouts 1.1 import "." Item { property string optionName: "Option" property variant comboModel RowLayout{ width: parent.width height: parent.height spacing: 0 Rectangle{ Layout.preferredWidth: parent.width*2/3 Layout.preferredHeight: parent.height color: "transparent" Rectangle{ anchors.fill: parent anchors.leftMargin: parent.width/10 color: "transparent" Text { id: textOption text: optionName color: Style.textColor font.family: localFont.name font.pixelSize: 12 anchors.verticalCenter: parent.verticalCenter } } } Rectangle{ id:value Layout.preferredWidth: parent.width*1/3 Layout.preferredHeight: parent.height Layout.alignment: Qt.AlignRight color: "transparent" ComboBox { width: parent.width*0.90 model : ListModel{ ListElement { text: "Français"; color: "Yellow" } ListElement { text: "English"; color: "Green" } ListElement { text: "German"; color: "Brown" } ListElement { text: "Dansk"; color: "Brown" } ListElement { text: "Español"; color: "Brown" } ListElement { text: "Polski"; color: "Brown" } ListElement { text: "Český"; color: "Brown" } } } } } }
The listview :
ListView { id: dataView anchors.top: barreLuminosite.bottom anchors.bottom: parent.bottom anchors.left: leftSpacer.right anchors.right: rightSpacer.left clip: true spacing : 2 model: OptionGenModel{} delegate: OptionDelegate{} }
The model OptionGenModel :
ListModel { id: optionGenModel ListElement { type: "combo" comboModel : [ ListElement { text: "Français"; color: "Yellow" }, //Not used for now ListElement { text: "English"; color: "Green" }, ListElement { text: "German"; color: "Brown" }, ListElement { text: "Dansk"; color: "Brown" }, ListElement { text: "Español"; color: "Brown" }, ListElement { text: "Polski"; color: "Brown" }, ListElement { text: "Český"; color: "Brown" }] optionName : qsTr("Langues : ") } ListElement { type: "date" } }
The OptionDelegate :
Item { id: multiDelegate height: multiDelegate.ListView.view.height/8 width: multiDelegate.ListView.view.width function bestDelegate(t) { switch(t){ case "combo" : return comboDelegate; break; case "date" : return dateDelegate; break; case "heure": return heureDelegate; break; case "switch": return switchDelegate; break; case "usine" : return usineDelegate; break; default : return console.log("Type not found") } } Component { id: dateDelegate OptionDate { id: date clickDate.onClicked: ouvrirDate() height: parent.height width: parent.width } } Component { id: comboDelegate ComboOption{ id: langues height: parent.height width: parent.width nomOption: optionName } } Loader { id: itemDisplay anchors.fill: parent; anchors.topMargin: 2 anchors.bottomMargin: 2 sourceComponent: bestDelegate(type) } } function ouvrirDate(){ //do something }
Is there any reason for this problem ?