Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. sorting qlistwidget items
Forum Update on Monday, May 27th 2025

sorting qlistwidget items

Scheduled Pinned Locked Moved Unsolved General and Desktop
sortingqlistwidget
6 Posts 4 Posters 5.4k 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.
  • L Offline
    L Offline
    Lorence
    wrote on last edited by
    #1

    im trying to sory qlistwidget items

    sortItems(Qt::AscendingOrder);
    when i call this function, the items are sucessfully sorted but i have to trigger an event (ie. right click on listwidget,leftclick,or anything) before it show the sorted items.

    M 1 Reply Last reply
    0
    • M Offline
      M Offline
      mchinand
      wrote on last edited by
      #2

      Does it display them sorted if you call update() after sorting the items?

      1 Reply Last reply
      0
      • L Lorence

        im trying to sory qlistwidget items

        sortItems(Qt::AscendingOrder);
        when i call this function, the items are sucessfully sorted but i have to trigger an event (ie. right click on listwidget,leftclick,or anything) before it show the sorted items.

        M Offline
        M Offline
        mjsurette
        wrote on last edited by
        #3

        @Lorence
        Have you tried calling invalidate() on your model?

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

          Hi,

          Can you show how your are setting up your QListWidget ?

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

          L 1 Reply Last reply
          0
          • SGaistS SGaist

            Hi,

            Can you show how your are setting up your QListWidget ?

            L Offline
            L Offline
            Lorence
            wrote on last edited by Lorence
            #5

            @SGaist

            my QListWidget object in ui is a MyListWidget

            heres my contrsuctor
            MyListWidget::MyListWidget(QWidget* parent)
            :QListWidget(parent)
            {

            }

            what do you mean by "how i set up my qlistwidget"?

            L 1 Reply Last reply
            0
            • L Lorence

              @SGaist

              my QListWidget object in ui is a MyListWidget

              heres my contrsuctor
              MyListWidget::MyListWidget(QWidget* parent)
              :QListWidget(parent)
              {

              }

              what do you mean by "how i set up my qlistwidget"?

              L Offline
              L Offline
              Lorence
              wrote on last edited by
              #6

              @Lorence now its working, i dont know what happens yesterday

              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