Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Issue using combobox on Listview
Forum Updated to NodeBB v4.3 + New Features

Issue using combobox on Listview

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 454 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DavidM29
    wrote on last edited by
    #1

    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 ?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DavidM29
      wrote on last edited by
      #2

      Obviously this is due to the fact that on QuickCOntrols 1.x Qt use a Window to show the popup of a combo box but my app already use a Window so Qt can't use the window over a window.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved