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. Wrong order in combobox

Wrong order in combobox

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
6 Posts 3 Posters 1.0k 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.
  • T Offline
    T Offline
    themts
    wrote on last edited by
    #1

    Hey guys,

    I have a c++ model (subclass of QAbstractListModel).
    When I use it with a combobox the ordering is completely wrong.
    Example:
    My model has 5 Items: 1, 2, 3, 4, 5
    When I assign it to a listview it is ordered as expected, when I assign it to a combobox, it looks like this:
    item 1
    item 5
    item 2
    item 4
    item 3

    Any idea, what could be wrong here?

    CU
    mts

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Can you share the code you use to initialize the combo box ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • T Offline
        T Offline
        themts
        wrote on last edited by
        #3

        Its quite simple

            ComboBox {
                id: comboBox1
                height: 20
                anchors.right: parent.right
                anchors.left: parent.left
                anchors.top: parent.top
                anchors.leftMargin: 5
                anchors.rightMargin: 5
                anchors.topMargin: 20
        
                model: appLogic.presetListModel
                textRole: "name"
            }
        
        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          What about the model ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • jpnurmiJ Offline
            jpnurmiJ Offline
            jpnurmi
            wrote on last edited by
            #5

            Did you use an asynchronous Loader? It's known to cause issues like this...

            1 Reply Last reply
            0
            • T Offline
              T Offline
              themts
              wrote on last edited by
              #6

              @jpnurmi
              No, the model comes from c++ and is already created before "engine.load(...)"

              @SGaist
              The model is based on Thomas Boutroues QQmlObjectListModel (link git-repository)
              The model is represented by this object:
              QQmlObjectListModel<NPreset>* presetListModel

              The NPreset Class has around 10 Q_PROPERTYs, one is Q_PROPERTY(QString name ...)

              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