Question

I'm updating some old code that is unfortunately heavily dependent on Q3ListView and Q3ListViewItem, its now-obsolete little helper class.

I'm assuming I can now just populate a QListView without the item layer, but in looking through the documentation, I still don't have a very good grip on that. One tutorial I found fills a QStandardItemModel with QStandardItems and then sets that as the model to the QListView, but I also came across a QAbstractListModel class that looks like it might be interesting. A couple of questions have come up:

-Is a QListView basically populated by setting some "model" to it, which itself is populated with items?

-In the old version I have, the Q3ListViewItem is subclassed like this:

class OurListItem : public Q3ListViewItem {
   public: 
      OurListItem(Q3ListView* parent) :Q3ListViewItem(parent) {ourData = NULL;}
      OurListItem(Q3ListViewItem* parent) :Q3ListViewItem(parent) {ourData = NULL;}
      Data* ourData; 
}; 

Considering the options available now, what is the best way to re-implement this idea?

Was it helpful?

Solution

Depending on how clean you want the conversion to be, and how quickly you want to do the conversion, you may also want to look at QListWidget and QListWidgetItem. They are the approximate analogues in Qt4, and I think the conversion to them was usually straightforward. As I recall (it's been quite a while), the Qt3 versions of those classes may also have had table or tree abilities (rather than just a simple list), so you may also be interested in QTableWidget and QTreeWidget (and their associated item classes).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top