Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. SIGSEGV tableitem->text()
Forum Updated to NodeBB v4.3 + New Features

SIGSEGV tableitem->text()

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 2.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kumpane
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kumpane
      wrote on last edited by
      #2

      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?

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved