Table widget 中itemAt
时间: 2023-11-13 22:05:05 浏览: 74
tablewidget'
In Qt, the `QTableWidget` class provides a method called `itemAt()` which returns a pointer to the item at the given position in the widget's coordinate system. The method takes two integer arguments, `x` and `y`, which represent the horizontal and vertical position of the item.
Here's an example usage of `itemAt()`:
```python
# Assuming that we have a QTableWidget instance called "tableWidget"
item = tableWidget.itemAt(2, 3) # Returns the item at row 2, column 3
if item is not None:
print(f"Item text: {item.text()}")
else:
print("No item found at the given position")
```
This code snippet retrieves the item at row 2, column 3 of the `tableWidget` instance and prints its text if it exists. If no item is found at the given position, a message is printed indicating so.
阅读全文