Results 1 to 7 of 7

Thread: [QT4] Defining second QTreeWidget in header == segfault?

  1. #1
    Join Date
    Jan 2006
    Posts
    44
    Thanks
    9
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11

    Default [QT4] Defining second QTreeWidget in header == segfault?

    I've got a MainWIndow subclass. In MainWindow.h I have
    Qt Code:
    1. ...
    2. QTreeWidget *l_treeWidget;
    3. ...
    To copy to clipboard, switch view to plain text mode 

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

    Now, I need to add a second one:
    Qt Code:
    1. ...
    2. QTreeWidget *l_treeWidget;
    3. QTreeWidget *w_treeWidget;
    4. ...
    To copy to clipboard, switch view to plain text mode 

    And it segfaults. No need to even try to use it, simply declaring it in the class definition causes a segfault. Any ideas?
    Last edited by ucntcme; 15th September 2007 at 21:32. Reason: adding clarification of QT version
    --
    The Real Bill

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: [QT4] Defining second QTreeWidget in header == segfault?

    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.

  3. #3
    Join Date
    Jan 2006
    Posts
    44
    Thanks
    9
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11

    Default Re: [QT4] Defining second QTreeWidget in header == segfault?

    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.
    --
    The Real Bill

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: [QT4] Defining second QTreeWidget in header == segfault?

    How do you initialize w_treeWidget?

  5. #5
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: [QT4] Defining second QTreeWidget in header == segfault?

    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

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: [QT4] Defining second QTreeWidget in header == segfault?

    Try recompiling the whole project (make distclean && qmake && make), it sometimes helps.

  7. The following user says thank you to wysota for this useful post:

    ucntcme (15th September 2007)

  8. #7
    Join Date
    Jan 2006
    Posts
    44
    Thanks
    9
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11

    Default Re: [QT4] Defining second QTreeWidget in header == segfault?

    Thanks wysota, that seems to have resolved it.
    --
    The Real Bill

Similar Threads

  1. Two-row header for QTreeWidget
    By wetzel in forum Qt Programming
    Replies: 1
    Last Post: 27th May 2006, 13:26

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.