7

I don't do a lot of Qt programming so this may sound like a silly question, but what happened to QListViewItem in qt4?

I have this application I wrote some time ago in qt3. I changed that to qt4 using the aptly name "qt3toqt4" program (all this on a Fedora platform).

Internally it seems to change a lot of classes from QClass to Q3Class (probably to provide some sort of backwards compatibility) and then compile it with qt4. I had some problems with it today (to do with reading stdout from a QProcess, but that aside) and I decided to simply rewrite the application in qt4.

Now for the problem - I use a QListView and to this I add loads of QListViewItems in a tree like structure. Something like this:

enter image description here

But that doesn't seem to be available anymore in qt4. And I can't find any examples that provide this behaviour either. Is there a way to do this in qt4? To maybe make it more complicated - I used my own QListViewItems (derived from QListViewItem) ...

Daniel Hedberg
  • 5,677
  • 4
  • 36
  • 61
Lieuwe
  • 1,734
  • 2
  • 27
  • 41

2 Answers2

3

The widget you are looking for in Qt 4 is QListWidget and its item class QListWidgetItem. It pretty much corresponds to the QListView widget in Qt 3 with a classic item-based interface for adding and removing items. You can subclass QListWidgetItem just as you subclassed QListViewItem in Qt 3.

Daniel Hedberg
  • 5,677
  • 4
  • 36
  • 61
  • Close. After trying your suggestion for a while I found out that there is also a QTreeView and QTreeViewItem .. and it is those I need. Thanks for pointing me into a semi correct direction .. – Lieuwe Feb 07 '13 at 20:40
  • Ah, I read your question in a hurry and missed that you were organizing things in a tree. Sorry. There's no such thing as a QTreeViewItem in Qt 4, but you probably mean QTreeWidget and QTreeWidgetItem? – Daniel Hedberg Feb 07 '13 at 21:02
1

Just to complete this question. It is QTreeWidget and QTreeWidgetItem that implement this behaviour in qt4.

Lieuwe
  • 1,734
  • 2
  • 27
  • 41