Unsolved How I remove content of data from a row in PySide2 without deleting the row
-
How I remove all data from a row in PySide2 without deleting the row, I try with setRowCount but not succeed I want to delete the content of data in a selected row in one table which will reflect another table as well
-
Hi,
Which widget are you using ?
Which model are you using ? -
I am Using QTableWidget in pySide2
-
@yashi95 use:
for column in range(your_tablewidget.columnCount()): item = QTableWidgetItem() your_tablewidget.setItem(row, column, item)
-
@eyllanesc Rather than recreating items all the time just empty the content of the ones already existing.
for column in range(your_tablewidget.columnCount()): your_tablewidget.item(row, column).setText("")
-
@SGaist thank you, but can you tell me if I have one table in that I have some data and one delete button and also I have one more table with the same content but I select the only first table of the row which have delete button when I click on delete button data should delete both tables
-
If you are showing the exact same content on several widget then you should rather go with a QTableView and share a QStandardItemModel between the two. If you want to stay with QTableWidget then you have to do the synchronisation yourself.
-
@SGaist okay understood thank you
-
@SGaist Can you tell me how we can find row through the content or data/item in the QtableWidget?
-
@yashi95
Look at:
https://doc.qt.io/qt-5/qtablewidget.html#item
https://doc.qt.io/qt-5/qtablewidget.html#itemFromIndex
https://doc.qt.io/qt-5/qtablewidget.html#findItems
https://doc.qt.io/qt-5/qtablewidget.html#indexFromItemDepending on what you have/what you want map to, any of these may be relevant.