Maybe it is a very lame question, but I am struggling with SIGSEGVs and really don't know what I am doing wrong...

I have a QTableWidget constructed via designer. I can use it in a program as ui->mytable. Everything is just fine as long as I don't want to create a new QTableWidgetItem via program.

At first, I set number of columns to 3 and rows to 0 and set text.

Qt Code:
  1. ui->mytable->setColumnCount(3);
  2. ui->mytable->setRowCount(0);
  3.  
  4. QStringList tblLabels;
  5. tblLabels << "blah1" << "blah2" << "blah3";
  6. ui->mytable->setHorizontalHeaderLabels(tblLabels);
To copy to clipboard, switch view to plain text mode 

Next, I have a button which adds one single row at a time.

Qt Code:
  1. int row;
  2. row = ui->mytable->rowCount();
  3. ui->mytable->setRowCount(row + 1);
To copy to clipboard, switch view to plain text mode 

This successfully adds one row, which is editable, everything is working fine. If I try to read or modify cell, which was already written from UI, everything works. But I want to predefine cell values for whole row. I am doing it as it is written in the manual. To create new items on empty row (current row), I just do:

Qt Code:
  1. int row;
  2. QTableWidgetItem *item1 = new QTableWidgetItem("1st value");
  3. QTableWidgetItem *item2 = new QTableWidgetItem("2nd value");
  4. QTableWidgetItem *item3 = new QTableWidgetItem("3rd value");
  5. row = ui->mytable->currentRow();
  6. ui->mytable->setItem(row,0,item1);
  7. ui->mytable->setItem(row,1,item2);
  8. ui->mytable->setItem(row,2,item3);
To copy to clipboard, switch view to plain text mode 

The setItem call fails with SIGSEGV... Not have a clue why. I tried to create own subclass of QTableWidget and do its own initialization, again with SIGSEGV. The whole row is created with three columns, but I cannot add new items via program.

Thank you for any help !