[bt-devel] tree keys and Qt4 Model/View architecture
Eeli Kaikkonen
eekaikko at mail.student.oulu.fi
Wed Jun 6 10:05:54 MST 2007
I noticed, as did Benjie, that there is something wrong with KListView.
It seems to exist no more though it's not told in porting document and
underlying Qt3 QListView has been removed/changed radically. Model/View
architecture is recommended in Qt docs.
So I tried to port cbooktreechooser. With many many hours of work I
found out how the Qt classes work, and honestly, I still don't
understand. But I managed to write a simple demo app which uses
sword::treekeyidx for data, QAbstractItemModel for model which handles
data, and QTreeView for view. What was really unbelievable was that
after I get it to compile, it worked with first try.
Anyways, you should be able to compile it with KDevelop or plain qmake.
It's in http://iki.fi/eelik/sword/keytreetest.tar.gz. The qmake project
file is tweaked for my Kubuntu installation. The app requires
"Institutes" module, it can be changed from main.cpp.
I would be thankful if Martin or someone else with more experience would
look at it. It feels quite slow. Is it othewise what is wanted? I
can't get BT 1.6.2 General Book keychooser to work as a tree - it only
shows the first level.
One thing which might make this slow is that it uses data without an
item class. Maybe initializing special items with key data would do the
trick.
Qt4 docs:
http://doc.trolltech.com/4.2/qabstractitemmodel.html
http://doc.trolltech.com/4.2/qmodelindex.html
http://doc.trolltech.com/4.2/qtreeview.html
http://doc.trolltech.com/4.2/itemviews-simpletreemodel.html
http://doc.trolltech.com/4.2/model-view-programming.html
Yours,
Eeli Kaikkonen (Mr.), Oulu, Finland
e-mail: eekaikko at mailx.studentx.oulux.fix (with no x)
More information about the bt-devel
mailing list