SIGSEGV tableitem->text()



  • I have to write a funktion which is matching the content between a QTreeWidget and the QTableWidget.
    I'm pretty sure i got the same problem like here http://lists.trolltech.com/qt-interest/2006-02/thread01488-0.html
    I try it with that if clause if(!tableitem) but the error appears anyway. The findItems functions works great and the text() function in the top works great too. I follow the behavior in the debugger a couple of times and all the time it is the tableitem which i used in the top too. The treeitem is not the problem. After the erros appears the debugger jump into qtablewidget.h.

    Here is a picture of the data with the debugger
    http://imageshack.us/photo/my-images/835/bildschirmfotoam2012011.png

    @ //qtablewidget.h line 107
    inline QString text() const
    { return data(Qt::DisplayRole).toString(); }
    inline void setText(const QString &text);
    @

    @
    QList<QTreeWidgetItem*> treelist=ui->treeMux->findItems("PORT ",Qt::MatchContains| Qt::MatchRecursive,0);
    QList<QTableWidgetItem*> tablelist=ui->tableTS->findItems("^[0-9]{1,2}$",Qt::MatchRegExp);

    foreach(QTableWidgetItem* tableitem,tablelist)
    {
    if(!tableitem)
    {continue;}
    else
    {
    if(tableitem->row()==0)
    {
    muxmaker->set_vects1(tableitem->column(),tableitem->text()); // HERE IT WORKS!
    ts1--;
    }
    if(tableitem->row()==1)
    {
    muxmaker->set_vects2(tableitem->column(),tableitem->text()); // HERE IT WORKS TOO!
    ts2--;
    }
    foreach(QTreeWidgetItem* treeitem,treelist)
    {
    treeitem->setCheckState(2,Qt::Unchecked);
    if(treeitem->text(0).contains(tableitem->text())) // HERE IS THE ERROR WITH tableitem->text()
    treeitem->setCheckState(2,Qt::Checked);
    }
    }
    }
    @

    The problem have to be so simple that i couldnt see it .... please excuse me fo my foolery



  • ops.....in the debugger picture you wil see a variable called strr , i add the variable to see if it is the treeitem or the tableitem...here is the code it will explain "everyting"
    @
    treeitem->setCheckState(2,Qt::Unchecked);
    QString strr = treeitem->text(0);
    if(strr.contains(tableitem->text()))
    treeitem->setCheckState(2,Qt::Checked);
    @

    if i try this it crashs
    @ QString str=tableitem->text();
    @

    if i try this it works
    @ cout<<tableitem->text().toStdString()<<endl;
    @

    What is the problem?? Maybe it is the Display Role?? or something like else?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.