[Qt-interest] assert() when calling QTreeView::header()->setResizeMode( section ) on a hidden view

Jan Kundrát jkt at gentoo.org
Wed May 13 19:57:58 CEST 2009


Hi, I have subclassed QTreeView as I want to overload the
sizeHintForColumn(). I also want the second column to be fixed-size, so
I tried to call:

tree->header()->setResizeMode( offset, QHeaderView::Fixed );

This resulted in a failed assertion "visual != -1" in file
itemviews/qheaderview.cpp, line 1168. I tried to call this from the
following places and all had the same result:

* In the constructor of my class derived from QTreeView
* Right after creating an instance of my derived class with no parent
* After adding that instance to a QSplitter which was set as a main
widget of a QMainWindow in its constructor (of the main window)

So unless I'm terribly mistaken, all cases were before the event loop
started and the widget got visible.

It works when I do that in a slot connected to the geometriesChanged()
signal of the header view. That doesn't seem like a nice fix, so I
wonder when is it safe to call this function?

Cheers,
-jkt

-- 
cd /local/pub && more beer > /dev/mouth

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090513/74d9147d/attachment.bin 


More information about the Qt-interest-old mailing list