PDA

View Full Version : [QT4] Defining second QTreeWidget in header == segfault?



ucntcme
15th September 2007, 21:31
I've got a MainWIndow subclass. In MainWindow.h I have


...
QTreeWidget *l_treeWidget;
...


And it works fine. I use it, it works. Beautiful.

Now, I need to add a second one:


...
QTreeWidget *l_treeWidget;
QTreeWidget *w_treeWidget;
...


And it segfaults. No need to even try to use it, simply declaring it in the class definition causes a segfault. Any ideas?

marcel
15th September 2007, 21:39
I think you know that what you say is practically impossible...
You must have a reference to it somewhere in your code.

Try to allocate the second tree widget in the constructor of you class and see if it crashes again.

ucntcme
15th September 2007, 22:02
Trust me, I know. :( It started last night, so I went to bed and slept on it. Same thing today.

If I simply create a new one in the constructor without specifying it in the header, it works. And nope, no references to it anywhere. It's brand new.

However thinking it may have been a funky build of Qt, I did a Qt upgrade(from 4.3.0 to 4.3.1) and now it seems to have stopped.

jacek
15th September 2007, 22:02
How do you initialize w_treeWidget?

marcel
15th September 2007, 22:13
I meant leaving the second tree widget a class member and also initialize it in the constructor.

Otherwise, maybe you could post some code.

Regards

wysota
15th September 2007, 22:52
Try recompiling the whole project (make distclean && qmake && make), it sometimes helps.

ucntcme
15th September 2007, 23:14
Thanks wysota, that seems to have resolved it.