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. QTableWidget How to Deselect Row
Qt 6.11 is out! See what's new in the release blog

QTableWidget How to Deselect Row

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 5.5k 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.
  • Q Offline
    Q Offline
    qt.1234
    wrote on last edited by
    #1

    Hello

    I have a QTableWidget on my form. I have two buttons, one to perform selection and the other button to perform deselection.

    For selection i use the following code:

    ui.tableWidget->selectRow(0);
    

    so first row will be selected on my QTableWidget.

    But how do i go about deselecting the row when the other button is pressed? I have tried the following but it did not work.

    ui.tableWidget->selectionModel()->clearSelection(); 
    

    Please advise. Thank you.

    JonBJ 1 Reply Last reply
    0
    • Q qt.1234

      Hello

      I have a QTableWidget on my form. I have two buttons, one to perform selection and the other button to perform deselection.

      For selection i use the following code:

      ui.tableWidget->selectRow(0);
      

      so first row will be selected on my QTableWidget.

      But how do i go about deselecting the row when the other button is pressed? I have tried the following but it did not work.

      ui.tableWidget->selectionModel()->clearSelection(); 
      

      Please advise. Thank you.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @qt-1234

      ui.tableWidget->clearSelection();
      

      (inherited from https://doc.qt.io/qt-5/qabstractitemview.html#clearSelection)?

      Q 1 Reply Last reply
      3
      • JonBJ JonB

        @qt-1234

        ui.tableWidget->clearSelection();
        

        (inherited from https://doc.qt.io/qt-5/qabstractitemview.html#clearSelection)?

        Q Offline
        Q Offline
        qt.1234
        wrote on last edited by
        #3

        @JonB oh!! it is working now! thank you.

        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