QTableWidget populating
-
Hi guys,
Back with another problem I'm afraid! I'm having terrible trouble filling a row in a QTableWidget.
The idea is simply that I load a file using the QFileDialog class which dumps its data into a QStringList. From here I need to get this data into the QTableWidget by creating a new row, then filling 4 seperate columns with data.
Could somebody please point me in the right direction?
Thanks
Andrew -
[quote author="VCsala" date="1292523877"]AFAIK QTableWidget inherits QTableView[/quote]
Indeed it does. You can consider the QWidget classes to be exactly like the QView classes, but with a builtin model (which closely resembles QStandardItemModel) and helper classes to manage this models (the QWidgetItem classes). Using a custom model with the QWidget classes is pointless, since you won't be able to use their helper classes to manage the model.
[quote author="VCsala" date="1292521276"]You should build a model inherited from QAbstractTableModel and set it as a basemodel for the QTableWidget.[/quote]
s/QTableWidget/QTableView/, see above.
-
-
The decision is not so easy. We use both the QxxWidgets and the QxxViews in our code. Sometimes it's more convenient to have a QxxWidgetItem subclass to add the functionality, especially if you only want to add a small improvement and are satisfied with the standard implementation for the rest. Although I must admit that we generally do not have big amounts of data in the Widgets, so speed and space optimization is not a big issue for us.
-