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. QTableWidget Read Cell Value
Forum Updated to NodeBB v4.3 + New Features

QTableWidget Read Cell Value

Scheduled Pinned Locked Moved Solved Qt for Python
2 Posts 2 Posters 8.9k 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.
  • M Offline
    M Offline
    msalih
    wrote on last edited by
    #1

    Hi, I try to make an desktop app that get some values from user and make some calculations and show result.
    I prepared my design from QtDesigner, convert design to code and all I want is just get the value from the table cell.

    Everywhere I research gives the code;

    # Get the first column and first row of table
    self.tableWidget.itemAt(0,0).text()
    

    Actually it works. I can get the value of first column and first row.

    # Try to get all 6 cells values
    self.tableWidget.itemAt(0,0).text()
    self.tableWidget.itemAt(0,1).text()
    self.tableWidget.itemAt(0,2).text()
    self.tableWidget.itemAt(1,0).text()
    self.tableWidget.itemAt(1,1).text()
    self.tableWidget.itemAt(1,2).text()
    

    But when I try to get other 5 cells values, it returns same value.

    After some investigation, I found that that itemAt(x,y) values are not indexes. They are pixels.
    I try to figure out how it works heuristicly.

    # this may gives second rows item
    self.tableWidget.itemAt(20,40).text()
    

    Isn't there a way for access the cells other than this weird method?

    Actually I don't want to access the cells with pixels, I just want to access them via index.

    JonBJ 1 Reply Last reply
    0
    • M msalih

      Hi, I try to make an desktop app that get some values from user and make some calculations and show result.
      I prepared my design from QtDesigner, convert design to code and all I want is just get the value from the table cell.

      Everywhere I research gives the code;

      # Get the first column and first row of table
      self.tableWidget.itemAt(0,0).text()
      

      Actually it works. I can get the value of first column and first row.

      # Try to get all 6 cells values
      self.tableWidget.itemAt(0,0).text()
      self.tableWidget.itemAt(0,1).text()
      self.tableWidget.itemAt(0,2).text()
      self.tableWidget.itemAt(1,0).text()
      self.tableWidget.itemAt(1,1).text()
      self.tableWidget.itemAt(1,2).text()
      

      But when I try to get other 5 cells values, it returns same value.

      After some investigation, I found that that itemAt(x,y) values are not indexes. They are pixels.
      I try to figure out how it works heuristicly.

      # this may gives second rows item
      self.tableWidget.itemAt(20,40).text()
      

      Isn't there a way for access the cells other than this weird method?

      Actually I don't want to access the cells with pixels, I just want to access them via index.

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

      @msalih
      QTableWidgetItem *QTableWidget::item(int row, int column) const.

      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