[Qt-interest] EditableTreeMode example crashing with modeltest
Daniel Price
daniel.price at fxhome.com
Wed Nov 25 12:11:55 CET 2009
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Tony Rietwyk
Sent: 24 November 2009 23:55
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] EditableTreeMode example crashing with modeltest
Unfortunately, QTreeView is also very ROW based. For example, it doesn't allow the background of the parent to extend beneath its visible children. You can't change the drop indicators that are drawn, etc. Reimplementing QTreeView is much easier said than done!
Not true!
http://doc.trolltech.com/main-snapshot/stylesheet-examples.html#customizing-qtreeview
-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Daniel Price
Sent: Tuesday, 24 November 2009 21:32
To: qt-interest List
Subject: [Qt-interest] EditableTreeMode example crashing with modeltest
I'm writing a tree model and I've used the Qt EditableTreeModel example (4.5.2) as a guide.
My model works fine when I had only one column of data but then behaves strangely when I have more than one column (child items added under other tree items do not always show up in the view).
I hooked up Qt's modeltest project (http://labs.trolltech.com/page/Projects/Itemview/Modeltest) and I don't get any errors or problems with one column when inserting child items. But with two columns of data, it asserts on line 328 with the test "index.isValid() == true" .
This code appears to the culprit:
QModelIndex TreeModelAdaptor::index(int row, int column, const QModelIndex &parent) const
{
if (parent.isValid() && parent.column() != 0)
return QModelIndex();
....
}
This was copied from the example - the test passes in a valid parent with a non-zero column and gets back an invalid model index, triggering the assert. But my model code is almost identical to the example.
Can someone explain this code? Why does the code return the root item in this case?
So I tried hooking up EditableTreeModel to ModelTest in MainWindow.cpp:
...
QFile file(":/default.txt");
file.open(QIODevice::ReadOnly);
TreeModel *model = new TreeModel(headers, file.readAll());
file.close();
new ModelTest(model, this);
view->setModel(model);
...
And it crashes at startup. Even with no data, the example crashes when used with ModelTest (in the debugger it breaks on qMalloc()).
Have the Qt examples been verified with ModelTest? Any idea as to what is going on?
Daniel Price
Software Engineer
FXhome Limited
________________________________
This email is confidential. It may also be privileged or otherwise protected by work product immunity or other legal rules. If you are not the intended recipient please notify the sender. Please delete the message from all places in your computer where it is stored. You should not copy the email or use it for any purpose or disclose its contents to any other person.To do so may be unlawful. Email is an informal means of communicating and may be subject to data corruption accidentally or deliberately. For this reason it is inappropriate to rely on advice contained in an email without obtaining written confirmation of it first.
FXhome Limited is a limited company registered in England and Wales. Registered number: 04172812. Registered office: The Henderson Business Centre, Ivy Road, Norwich, Norfolk, NR5 8BF, U.K.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091125/b696e427/attachment.html
More information about the Qt-interest-old
mailing list