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. QListWidget row and selection
Qt 6.11 is out! See what's new in the release blog

QListWidget row and selection

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 4.1k 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.
  • W Offline
    W Offline
    Wurstinator
    wrote on last edited by
    #1

    Hello,
    apparently, the currentRow() of a QListWidget is updated after its selection. So if I connect itemSelectionChanged() with a slot which calls currentRow(), the currentRow() function still returns the former selected row.
    Is this a bug? Or is it working correctly and it's just me not understand the sense of it?

    1 Reply Last reply
    0
    • L Offline
      L Offline
      leon.anavi
      wrote on last edited by
      #2

      What exactly do you want to achieve?

      "QListWidget":http://qt-project.org/doc/qt-4.8/qlistwidget.html offers a variety of singals such as itemChanged, itemActivated, itemClicked and so on which should fit your needs.

      http://anavi.org/

      1 Reply Last reply
      0
      • N Offline
        N Offline
        Neutron Stein
        wrote on last edited by
        #3

        use "void QListWidget::currentItemChanged ( QListWidgetItem * current, QListWidgetItem * previous )" instead of itemSelectionChanged(). it gives you the current and the previous item

        Never Seen !

        1 Reply Last reply
        0
        • W Offline
          W Offline
          Wurstinator
          wrote on last edited by
          #4

          Yes, I know how I could circumvent this issue but my question was whether this is a bug or intended by the developers. And if it's not a bug, why did they choose to do it that way?

          1 Reply Last reply
          0
          • W Offline
            W Offline
            Wurstinator
            wrote on last edited by
            #5

            Ok, nobody seems to know, so let me ask a slightly different question:
            If a slot uses both currentRow() and selectedItems(), do I have to connect it with both corresponding signals to be assured that everything will be executed correctly?

            I saw this in the undo demo:
            @ connect(doc->undoStack(), SIGNAL(indexChanged(int)), this, SLOT(updateActions()));
            connect(doc->undoStack(), SIGNAL(cleanChanged(bool)), this, SLOT(updateActions()));@
            The second line seems to be unnecessary but updateActions() calls doc-undoStack()->isClean(), which might give a wrong return value in the first "connect"-call.

            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