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 Select Row
Qt 6.11 is out! See what's new in the release blog

QTableWidget Select Row

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 3.8k 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.
  • H Offline
    H Offline
    hubeytqew
    wrote on last edited by
    #1

    Hi, I have a table which is a created with QTableWidget. I want to delete a row(with variables ofc.) when user clicks/selects that row.
    How can I return a user selected row? I searched but did not get it right.

    jsulmJ 1 Reply Last reply
    0
    • A.A.SEZENA Offline
      A.A.SEZENA Offline
      A.A.SEZEN
      wrote on last edited by
      #5
      QModelIndex index = table->selectionModel()->currentIndex();
      if(table->item(index.row(), 0))
          ..................
      
      H 1 Reply Last reply
      2
      • H hubeytqew

        Hi, I have a table which is a created with QTableWidget. I want to delete a row(with variables ofc.) when user clicks/selects that row.
        How can I return a user selected row? I searched but did not get it right.

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @hubeytqew You can use https://doc.qt.io/qt-6/qtablewidget.html#selectedRanges, https://doc.qt.io/qt-6/qtablewidgetselectionrange.html contains the top and bottom rows.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        H 1 Reply Last reply
        0
        • jsulmJ jsulm

          @hubeytqew You can use https://doc.qt.io/qt-6/qtablewidget.html#selectedRanges, https://doc.qt.io/qt-6/qtablewidgetselectionrange.html contains the top and bottom rows.

          H Offline
          H Offline
          hubeytqew
          wrote on last edited by
          #3

          @jsulm can you give me an example of usage?

          jsulmJ 1 Reply Last reply
          0
          • H hubeytqew

            @jsulm can you give me an example of usage?

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #4

            @hubeytqew What is not clear? You call selectedRanges and you get QList<QTableWidgetSelectionRange>. Then you iterate over the list entries (QTableWidgetSelectionRange) and in each entry you have topRow() and bottomRow()...

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            1
            • A.A.SEZENA Offline
              A.A.SEZENA Offline
              A.A.SEZEN
              wrote on last edited by
              #5
              QModelIndex index = table->selectionModel()->currentIndex();
              if(table->item(index.row(), 0))
                  ..................
              
              H 1 Reply Last reply
              2
              • A.A.SEZENA A.A.SEZEN
                QModelIndex index = table->selectionModel()->currentIndex();
                if(table->item(index.row(), 0))
                    ..................
                
                H Offline
                H Offline
                hubeytqew
                wrote on last edited by
                #6

                @A-A-SEZEN thats what I expect..thanks

                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