[Qt-interest] QTreeView + Custom Model
Andreas Pakulat
apaku at gmx.de
Sat Aug 29 20:35:35 CEST 2009
On 29.08.09 19:05:44, Oliver Ney wrote:
> I am currently trying to get a QTreeView with a custom Model working.
> My problem is, that the QTreeView displays all top level elements and
> also shows the [+]/[-] box if there are child elements, but it does not
> expand the elements. Which means that [+] changes into [-] and the tree
> stays collapsed.
>
> By adding debugging messages to my code I found out that the QTreeView
> calls the index() function of my model with row = -1 when it's asked to
> expand the tree.
>
> I've already read all parts of the Qt Model/View-Framework pages in the
> documentation for this and also used the TreeView example in the docs as
> a reference.
>
> The data I'm displaying in the TreeView comes from a MySQL database but
> I can't use QSqlTableModel for it.
>
> I've written some testing code for model, which I think should show that
> it works fine.
I suggest you use the "official" model test against your model:
http://labs.trolltech.com/page/Projects/Itemview/Modeltest
> This is how I understood the models work. So I don't get it why the
> TreeView asks for row -1. And doesn't display and child elements.
Because it can, there's nothing forbidding the treeview to ask for
invalid rows/columns.
Andreas
--
An avocado-tone refrigerator would look good on your resume.
More information about the Qt-interest-old
mailing list