Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Weird ComboBox behavior

    QML and Qt Quick
    qml combobox loader
    2
    4
    1270
    Loading More Posts
    • 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
      Smatcher last edited by

      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 Reply Quote 0
      • B
        bnogal last edited by

        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 Reply Quote 0
        • S
          Smatcher @bnogal last edited by

          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 Reply Quote 0
          • B
            bnogal last edited by

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

            1 Reply Last reply Reply Quote 0
            • First post
              Last post