Results 1 to 2 of 2

Thread: QTreeWidgetItem - segmentation fault

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2007
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QTreeWidgetItem - segmentation fault

    Hi!

    I'm trying to send QTreeWidgetItem* using itemClicked(QTreeWidgetItem*, int) signal but when I'm using in my slot item->text(column_nr) I always get segmentation fault in moment when I click on some item in QTreeWidget tree.
    Compilation runs without errors or warnings. Here are some fragments of my program:


    base class with connect
    Qt Code:
    1. DirView *dirView = new DirView;
    2. TagView *tagView = new TagView;
    3.  
    4. connect(dirView, SIGNAL(itemClicked(QTreeWidgetItem*, int)), tagView, SLOT(setTags(QTreeWidgetItem*, int)));
    To copy to clipboard, switch view to plain text mode 


    my slot in tagView
    Qt Code:
    1. void TagView::setTags(QTreeWidgetItem* item, int)
    2. {
    3. if(item != 0)
    4. item->text(0);
    5. }
    To copy to clipboard, switch view to plain text mode 


    dirView constructor (interhits from QTreeWidget)
    Qt Code:
    1. DirView::DirView(QWidget *parent) : QTreeWidget(parent)
    2. {
    3. model = new QDirModel;
    4.  
    5. QStringList nameFilters;
    6. nameFilters << "*.mp3" << "*.ogg" << "*.flac" << "*.mpc" << "*.wav" << "*.aac" << "*.wma" << "*.ape" << "*.mpp" << "*.mp4";
    7. model->setNameFilters(nameFilters);
    8.  
    9. QTreeView::setModel(model);
    10.  
    11. QTreeView::header()->setSectionHidden(1, true);
    12.  
    13. QTreeView::header()->resizeSection(0, 280);
    14. QTreeView::header()->resizeSection(2, 100);
    15. QTreeView::header()->resizeSection(3, 100);
    16.  
    17. this->setRootIndex(model->index(QDir::rootPath()));
    18. }
    To copy to clipboard, switch view to plain text mode 


    If it's not enough I can show all code. I have no idea why I can't use item->text(). Signal is generated in appropriate moment but when I'm using text() in slot program crashes.

    Anyone can help?

  2. #2
    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: QTreeWidgetItem - segmentation fault

    You can't set a new model on a tree widget! Use QTreeView instead.

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

    szczav (5th June 2007)

Similar Threads

  1. Process aborted. Segmentation fault
    By Pragya in forum Qt Programming
    Replies: 3
    Last Post: 30th May 2007, 08:12
  2. Segmentation fault running any QT4 executables
    By jellis in forum Installation and Deployment
    Replies: 7
    Last Post: 19th May 2007, 16:35
  3. segmentation fault insert QString in QCombobox
    By regix in forum Qt Programming
    Replies: 16
    Last Post: 8th August 2006, 08:46
  4. Icons missing => segmentation fault
    By antonio.r.tome in forum Qt Programming
    Replies: 4
    Last Post: 8th March 2006, 16:30
  5. [qmake_image_collection.cpp] Segmentation fault
    By CrazyLegz in forum KDE Forum
    Replies: 1
    Last Post: 4th February 2006, 11:43

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.