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: click item then click white space, QListWidget.currentRow() will not change ?
Qt 6.11 is out! See what's new in the release blog

QListWidget: click item then click white space, QListWidget.currentRow() will not change ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 1.6k 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.
  • sonichyS Offline
    sonichyS Offline
    sonichy
    wrote on last edited by sonichy
    #1

    QListWidget: click item then click white space, QListWidget.currentRow() will not change.
    I want when click white space , QListWidget will clear selected row like visually.
    The 2 way below will not emit signal when left click white space:

    connect(ui->listWidget,SIGNAL(clicked(QModelIndex)),this,SLOT(listWidgetClicked(QModelIndex)));
    

    or

    connect(ui->listWidget,SIGNAL(itemClicked(QListWidgetItem*)),this,SLOT(listWidgetItemClicked(QListWidgetItem*)));
    

    https://github.com/sonichy

    DiracsbracketD 1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Why would it ? , you are not changing the row since you are not hitting another new item. So selected row stays the same.

      1 Reply Last reply
      4
      • M Offline
        M Offline
        marhan
        wrote on last edited by marhan
        #3

        If it is a QListWidget - the SIGNAL is not correct

        void itemClicked(QListWidgetItem *item) (http://doc.qt.io/qt-5/qlistwidget.html)

        If you have a QListView then QModelIndex should work.

        1 Reply Last reply
        2
        • sonichyS sonichy

          QListWidget: click item then click white space, QListWidget.currentRow() will not change.
          I want when click white space , QListWidget will clear selected row like visually.
          The 2 way below will not emit signal when left click white space:

          connect(ui->listWidget,SIGNAL(clicked(QModelIndex)),this,SLOT(listWidgetClicked(QModelIndex)));
          

          or

          connect(ui->listWidget,SIGNAL(itemClicked(QListWidgetItem*)),this,SLOT(listWidgetItemClicked(QListWidgetItem*)));
          
          DiracsbracketD Offline
          DiracsbracketD Offline
          Diracsbracket
          wrote on last edited by Diracsbracket
          #4

          @sonichy Hey, don't forget to close your other posts if you are no longer interested in them, e.g.
          https://forum.qt.io/topic/90401/maxsize-argument-exceeds-qbytearray-size-limit
          https://forum.qt.io/topic/90474/qdatastream-write-file-size-to-file-header
          Cheers!

          1 Reply Last reply
          2

          • Login

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