Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Display bulk data on QTableWidget
Piyush last edited by
I need to display bulk data on QTableWidget, for which I need to show all the data at one go. Currently, I am running the following script which populates the data on QTableWidget in an item by item manner. I am using dataframe (python) to store data and showing it pushing data item by item on QtableWidget. This is how I am doing it right now:
self.ui.out_table.setRowCount(df.shape) for row in range (0, df.shape): for col in range (0, len(df.columns) + 1): data = str(final_data.iloc[row, col] ) self.ui.out_table.setItem(row, col, QTableWidgetItem(str(data)))
Is there a way by which I can display the complete dataframe in one go?
QTableWidget is item based and you give it data by inserting items.
Im not sure what you mean "in one go"
There is no way around using items.
You could use the View version and a custom model and store the data directly in model.
Alternatively, if its just so data is shown at same time, you can use
so it first draws when finished adding.
JonB last edited by
If you want to set several items of a particular row (say, by calling setItem() in a loop), you may want to turn off sorting before doing so, and turn it back on afterwards; this will allow you to use the same row argument for all items in the same row (i.e. setItem() will not move the row).