QItemSelection, does not copy all area
Hi, I have strange problem. I have two class: mainWindow inherits by QMainWindow, and myWidget inherits by QWidget. In mainWindow class i create model, and myWidget class i create QTableView. Now i would like copy selection, but not in myWidget, only mainWindow class, so i did something like this in myWidget:
Code:
connect(table->selectionModel(),SIGNAL(
And in mainWindow:
Code:
this,
SLOT(updateSelection
(const QItemSelection
&,
const QItemSelection &)));
this->selection = selection;
}
void mainWindow::copyCells(){
QList<QItemSelectionRange> models = selection;
if(models.isEmpty())
return;
for(int i=start.row(); i<=stop.row(); ++i) {
for(int j=start.column(); j<=stop.column(); ++j) {
if(model->item(i,j)->text() != "="){
text+= model->item(i,j)->text();
text += ' ';
}
}
text += '\n';
}
}
Now, when i select an area and try copy, it copy random value, further only one left or right column, or top or bottom row. Function copyCells works well, i tested it earlier. Where I make error?