Thanks, but looking like I feel myself not that experienced in Qt to use such a deep way.
Okay, I have modified the code and now it inserts rows perfectly (you were right, that was my fault). It copies the values from the old row to the new one with setItem() as you told. So I have
void DataTableWidget::onRowDown()
{
int crow = currentItem()->row();
insertRow(crow + 2);
setItem(crow + 2, 0, item(crow, 0));
setItem(crow + 2, 1, item(crow, 1));
setItem(crow + 2, 2, item(crow, 2));
removeRow(crow);
}
void DataTableWidget::onRowDown()
{
int crow = currentItem()->row();
insertRow(crow + 2);
setItem(crow + 2, 0, item(crow, 0));
setItem(crow + 2, 1, item(crow, 1));
setItem(crow + 2, 2, item(crow, 2));
removeRow(crow);
}
To copy to clipboard, switch view to plain text mode
I got SIGSEGV when I tried to removeRow(). I have commented it out and this code worked but the new row was somehow linked to the old one. I mean when I was changing data in the new row, the old one was changed in the same way and vice versa. Moreover when I had some changes in the widget and closed the dialogs, I had SIGSEGV too.
Then I tried to find a way how to remove the old cells and decided to get them by takeItem(), not by item(). So the final code looks like
void DataTableWidget::onRowDown()
{
int crow = currentItem()->row();
insertRow(crow + 2);
setItem(crow + 2, 0, takeItem(crow, 0));
setItem(crow + 2, 1, takeItem(crow, 1));
setItem(crow + 2, 2, takeItem(crow, 2));
removeRow(crow);
}
void DataTableWidget::onRowDown()
{
int crow = currentItem()->row();
insertRow(crow + 2);
setItem(crow + 2, 0, takeItem(crow, 0));
setItem(crow + 2, 1, takeItem(crow, 1));
setItem(crow + 2, 2, takeItem(crow, 2));
removeRow(crow);
}
To copy to clipboard, switch view to plain text mode
And this thing works, and removeRow() works too. At least when moving rows down 
Thank you so much, wysota!
Bookmarks