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. [Solved] How to de-select multiple cells in QTableWidget?

[Solved] How to de-select multiple cells in QTableWidget?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 7.4k 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.
  • CAD_codingC Offline
    CAD_codingC Offline
    CAD_coding
    wrote on last edited by
    #1

    Hi,

    For certain situation I have to manually select cells/column/row by code in my QTableWidget.
    Now the problem is that I cannot find any method like QTableWidget::clearSelection() which will deselect all selected cells. Currently the following happens:

    1. mySelectionFunction();//selects a row/column
    2. again call mySelectionFunction() for some other row/column; //previous row/column as well as current row/column are selected

    What I want is :

    1. mySelectionFunction();//selects a row/column
    2. myTable->clearSelection(); //clears all selected cells in QTableWidget
    3. again call mySelectionFunction() for some other row/column; //only current row/column is selected

    Any help in how to do step no. 2?
    Thanks!

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

      Hi,

      Something like "this":http://qt-project.org/doc/qt-4.8/qitemselectionmodel.html#clear ?

      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
      • CAD_codingC Offline
        CAD_codingC Offline
        CAD_coding
        wrote on last edited by
        #3

        Hi SGaist,

        Thanks a lot man!
        Works like a charm...

        Used this:

        QTableWidget->selectionModel()->clearSelection();

        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