PDA

View Full Version : pygtk to pyqt4 help



alexandernst
19th July 2009, 20:18
Hi all, I have this in pygtk:



self._model = gtk.TreeStore(gtk.gdk.Pixbuf, object, str, str, bool)
...
self._model.append(None, [None, None, gid, gid, False])


I want to convert this code to pyqt4. I'm using a QStandardItemModel.



self._model = QStandardItemModel(self)
...
self._model.appendRow(????????????????)


Is there something similar to gtk.TreeStore in pyqt4?

Thanks

Lykurg
19th July 2009, 20:44
With a simple lookup in the docs you could have found: QTreeView with a custom/existing model (e.g. QDirModel) or QTreeWidget with QTreeWidgetItem.
Or read the doc about QStandardItemModel there is a example for using it with a tree.

alexandernst
20th July 2009, 00:23
Thanks. I think I'll use the standarditemmodel.
I have another question, related to this one.

I'm using the QStandardItemModel, and I swear I red all the methods and I can't find nothing equivalent to GtkTreeModel::get_iter_first.
Can you help me?

Lykurg
20th July 2009, 09:16
can't find nothing equivalent to GtkTreeModel::get_iter_first.
I don't know what that iterator is for, but if you want to iterate through all items in your model, you could use two for-loops with rowCount and columnCount and construct a QModelIndex with index() out of them.