Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. How to get row number from QTableWidget based on input?
Forum Updated to NodeBB v4.3 + New Features

How to get row number from QTableWidget based on input?

Scheduled Pinned Locked Moved Unsolved Qt for Python
3 Posts 2 Posters 1.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.
  • Q Offline
    Q Offline
    qtDevOps
    wrote on last edited by
    #1

    I want to be able to get row number of specific item from QTableWidget.

    def getRowNumber(self):
            result = self.Table.findItems(
                self.QlineItemName.text(), QtCore.Qt.MatchFlag.MatchExactly)
    

    The problem is that it returns a list rather than the row number. How to get row number.

    Pl45m4P 1 Reply Last reply
    0
    • Q qtDevOps

      I want to be able to get row number of specific item from QTableWidget.

      def getRowNumber(self):
              result = self.Table.findItems(
                  self.QlineItemName.text(), QtCore.Qt.MatchFlag.MatchExactly)
      

      The problem is that it returns a list rather than the row number. How to get row number.

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by
      #2

      @qtDevOps

      • https://doc.qt.io/qt-5/qtablewidget.html#row

      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      1 Reply Last reply
      2
      • Q Offline
        Q Offline
        qtDevOps
        wrote on last edited by
        #3

        Solution to the question

        def getRowNumber(self):
                result = self.Table.findItems(
                    self.QlineItemName.text(), QtCore.Qt.MatchFlag.MatchExactly)
        
                rowNumber = result[0].row()
                print(f"Row number : {rowNumber}")
        
        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