Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 4

Qt-interest Archive, December 2007
QTreeView and custom model troubles


Message 1 in thread

Hi. I'm experiencing problems with Qt MVC framework. I have just create
simple model, that convert list of lines like ("/a/b/c/", "/a/b/d/",
"/a/b/e/f/", "/a/z/") to some kind of tree:

 a
 |-b
 | |-c
 | |-d
 | |-e
 |   |-f
 |-z


After attaching such model to QTreeView and expanding some node, I got
some assertion failure in QTreeView's private subclass (Qt/X11 4.3.3):

ASSERT: "i > -1" in file itemviews/qtreeview.cpp, line 2798
zsh: abort 

After spending some time with debugging, I've tried to wrap this model
intro QSortFilterProxyModel without any kind of sorting and filtering. Now
resulting model works as expected.

As far as I understand, this is problem with my Model, however same model
works correctly with QSortFilterProxyModel. 

Any ideas?

PS. I've attached source code of app that terminates with assertion
failure here. After uncommenting 3 lines of code in main.cpp (wrapping
model into QSortFilterProxyModel) app works.

-- 
 [ signature omitted ] 

Attachment: test.tar.gz
Description: Binary data

Attachment: signature.asc
Description: Digital signature


Message 2 in thread

Dmitry,

I haven't run your code, but you should run your model through Trolltech's 
ModelTest.  You can download it here. It has lots of information on why things 
might be asserting:

http://labs.trolltech.com/page/Projects/Itemview/Modeltest

--Justin

On Tuesday 25 December 2007 17:06:47 Dmitry Nezhevenko wrote:
> Hi. I'm experiencing problems with Qt MVC framework. I have just create
> simple model, that convert list of lines like ("/a/b/c/", "/a/b/d/",
> "/a/b/e/f/", "/a/z/") to some kind of tree:
>
>  a
>
>  |-b
>  |
>  | |-c
>  | |-d
>  | |-e
>  | |
>  |   |-f
>  |
>  |-z
>
> After attaching such model to QTreeView and expanding some node, I got
> some assertion failure in QTreeView's private subclass (Qt/X11 4.3.3):
>
> ASSERT: "i > -1" in file itemviews/qtreeview.cpp, line 2798
> zsh: abort
>
> After spending some time with debugging, I've tried to wrap this model
> intro QSortFilterProxyModel without any kind of sorting and filtering. Now
> resulting model works as expected.
>
> As far as I understand, this is problem with my Model, however same model
> works correctly with QSortFilterProxyModel.
>
> Any ideas?
>
> PS. I've attached source code of app that terminates with assertion
> failure here. After uncommenting 3 lines of code in main.cpp (wrapping
> model into QSortFilterProxyModel) app works.


--
 [ signature omitted ] 

Message 3 in thread

On Tue, Dec 25, 2007 at 05:36:37PM -0500, Justin Noel wrote:
> Dmitry,
> 
> I haven't run your code, but you should run your model through Trolltech's 
> ModelTest.  You can download it here. It has lots of information on why things 
> might be asserting:
> 
> http://labs.trolltech.com/page/Projects/Itemview/Modeltest
> 

Hi Justin. Thanks for this link. I got assertion failure with this test
too.. So now I have some kind of test case.

PS. There was no any info about Model testing in Qt documentation, however
this info is very useful. 

-- 
 [ signature omitted ] 

Attachment: signature.asc
Description: Digital signature


Message 4 in thread

On Wed, 2007-12-26 at 00:47 +0200, Dmitry Nezhevenko wrote:
> On Tue, Dec 25, 2007 at 11:31:13PM +0100, Stephan Rose wrote:
>  
> > All files already are listed in the .pro file so that isn't the
problem.
> > But that's just a listing of header files in the project. That
doesn't
> > define what header files are included in which source files.
> > 
> 
> This is not _just_ listing of header files in project. ".pro" file is
> source file for Makefile (that is generated by qmake).
> 
> qmake scans all header/source files from .pro and generate correct
> Makefile with all required target dependencies.

Ahh ok, I knew it creates the resulting makefiles but I didn't know it
also generated dependencies from that, thanks for the info.

> 
> However there is some problem with this such Makefile generator and
looks
> like it isn't solved by Qt integration plugin: If you decide to
include
> some local header file to source, you _should_ launch qmake again to
> update Makefile target dependencies, elsewhere, this source file will
not
> be rebuilded automatically after modifying header.

> So basically just run "qmake" to refresh target dependencies in
Makefile. 

Well the qt integration actually does already run qmake everytime I do a
build automatically to refresh the makefile. However, I did as you
suggested and ran it manually, even removed the old generated makefiles
first.

That worked just fine, it did it's job, created the new makefiles.

However, the dependency thing is not working right for me. I have one
file in my project, Scalar.h, that is included in virtually *every* file
that isn't purely UI related. My project is a CAD project and Scalar.h
defines a multi-unit capable scalar type so it is the very foundation
everything else builds on top of. There is virtually nothing that
doesn't use it one way or another.

So any change to Scalar.h should cause a recompile to almost the entire
project but it only caused a recompile to about 5 files which makes no
sense.

I even checked the .pro file to make sure every single header and source
file is listed and they are. Nothing seems to be missing there.

> 
> PS. There exists build systems that don't have such problems, like
CMake.

Hmmm thanks for the tip, I'll check that out.

Stephan

--
 [ signature omitted ] 

Message 5 in thread

There is docs and debug output in the actual code of that test class. It's not a supported Qt class, just something an engineer put together to help people with making custom models.  Look in the source and uncomment the debug output in the areas that crash.

--Justin

Sent from my BlackBerry® wireless device

-----Original Message-----
From: Dmitry Nezhevenko <dion@xxxxxxxxx>

Date: Wed, 26 Dec 2007 00:58:28 
To:qt-interest@xxxxxxxxxxxxx
Subject: Re: QTreeView and custom model troubles


On Tue, Dec 25, 2007 at 05:36:37PM -0500, Justin Noel wrote:
> Dmitry,
> 
> I haven't run your code, but you should run your model through Trolltech's 
> ModelTest.  You can download it here. It has lots of information on why things 
> might be asserting:
> 
> http://labs.trolltech.com/page/Projects/Itemview/Modeltest
> 

Hi Justin. Thanks for this link. I got assertion failure with this test
too.. So now I have some kind of test case.

PS. There was no any info about Model testing in Qt documentation, however
this info is very useful. 

-- 
 [ signature omitted ] 

Message 6 in thread

On Tue, Dec 25, 2007 at 11:08:36PM +0000, Justin Noel wrote:
> 
> There is docs and debug output in the actual code of that test class. It's not a supported Qt class, just something an engineer put together to help people with making custom models.  Look in the source and uncomment the debug output in the areas that crash.

Thanks again. Finally problem is fixed. My model's parent() method returns
Index with incorrect "row" property

-- 
 [ signature omitted ] 

Attachment: signature.asc
Description: Digital signature