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. Weird ComboBox behavior
QtWS25 Last Chance

Weird ComboBox behavior

Scheduled Pinned Locked Moved QML and Qt Quick
qmlcomboboxloader
4 Posts 2 Posters 1.6k Views
  • 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.
  • S Offline
    S Offline
    Smatcher
    wrote on 28 Oct 2015, 15:42 last edited by
    #1

    Hello everyone,

    I just stumbled on some weird behavior from the QML ComboBox. As soon as a ComboBox is located inside an asynchronous loaded component (It doesn't even have to be the Component top Item) the order of the ComboBox content is incorrect.
    The style of the popup menu when opening the ComboBox also differs from a synchronously loaded ComboBox
    The workaround I found is to to wrap the ComboBox inside a synchronous Loader.

    Is this the intended behavior ?

    Here is some sample code to illustrate this behavior

    import QtQuick 2.4
    import QtQuick.Controls 1.3
    import QtQuick.Window 2.2
    import QtQuick.Dialogs 1.2
    
    Window {
        id: win
        title: qsTr("Hello World")
        width: 640
        height: 480
        visible: true
    
        property var model: ["item 1", "item 2", "item 3", "item 4", "item 5", "item 6", "item 7", "item 8"]
    
        Component {
            id: comboCompo
            Column {
                ComboBox {
                    id: combo
                    model: win.model
                }
            }
        }
    
        Component {
            id: wrappedCompo
            Loader {
                sourceComponent: comboCompo
                asynchronous: false
            }
        }
    
        Grid {
            columns: 3
            anchors.fill: parent
            GroupBox {
                // [1]
                title: "Synchronous"
                Loader {
                    sourceComponent: comboCompo
                    asynchronous: false
                }
            }
    
            GroupBox {
                // [2]
                title: "Asynchronous"
                Loader {
                    sourceComponent: comboCompo
                    asynchronous: true
                }
            }
    
            GroupBox {
                // [3]
                title: "Wrapped Asynchronous"
                Loader {
                    sourceComponent: wrappedCompo
                    asynchronous: true
                }
            }
        }
    }
    
    1 Reply Last reply
    0
    • B Offline
      B Offline
      bnogal
      wrote on 28 Oct 2015, 16:52 last edited by
      #2

      i already reported this bug.

      The problem is with the instantiator element.
      When it runs async, it doesnt respect the order.
      search for the bug and vote up...
      by the moment, just dont use async, and care, because if a parent is loading a component async, and that component contains an instantiator (or a Combobox) your will get the same problem

      S 1 Reply Last reply 28 Oct 2015, 17:24
      0
      • B bnogal
        28 Oct 2015, 16:52

        i already reported this bug.

        The problem is with the instantiator element.
        When it runs async, it doesnt respect the order.
        search for the bug and vote up...
        by the moment, just dont use async, and care, because if a parent is loading a component async, and that component contains an instantiator (or a Combobox) your will get the same problem

        S Offline
        S Offline
        Smatcher
        wrote on 28 Oct 2015, 17:24 last edited by
        #3

        Thank you for your reply.

        I searched for the bug reports and only found reports about a crash when using Instantiator in an asynchronous Loader.
        I will upvote your bug report if I can find it.

        As for your suggestion to avoid async loader entirely it seems you are right. The workaround I talked about works in the simple example I gave but fails in more elaborate situations.

        1 Reply Last reply
        0
        • B Offline
          B Offline
          bnogal
          wrote on 29 Oct 2015, 08:41 last edited by
          #4

          https://bugreports.qt.io/browse/QTBUG-48053

          1 Reply Last reply
          0

          1/4

          28 Oct 2015, 15:42

          • Login

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