Qt-interest Archive, July 2007
QStandardItemModel takeRow and takeItem different result
Message 1 in thread
I two variant of a code, what just Upping row in one step:
////////////////////////////////////////////////
void cxmlLoadForm::on_btnUpRow_clicked()
{
int row = tbvXmlList->currentIndex().row();
if (row != -1 && row != 0)
{
QList <QStandardItem *>curRow;
curRow = tbvXmlListModel->takeRow(row);
tbvXmlListModel->insertRow(row-1, curRow);
tbvXmlList->selectRow(row-1);
}
}
////////////////////////////////////////////////
and this
////////////////////////////////////////////////
void cxmlLoadForm::on_btnUpRow_clicked()
{
int row = tbvXmlList->currentIndex().row();
if (row != -1 && row != 0)
{
QList <QStandardItem *>curRow;
QList <QStandardItem *>prevRow;
curRow << tbvXmlListModel->takeItem(row, 0)
<< tbvXmlListModel->takeItem(row, 1)
<< tbvXmlListModel->takeItem(row, 2);
prevRow << tbvXmlListModel->takeItem(row-1, 0)
<< tbvXmlListModel->takeItem(row-1, 1)
<< tbvXmlListModel->takeItem(row-1, 2);
for (int i=0; i < curRow.size(); i++)
{
tbvXmlListModel->setItem(row-1, i, curRow.at(i));
tbvXmlListModel->setItem(row, i, prevRow.at(i));
}
tbvXmlList->selectRow(row-1);
}
}
/////////////////////////////////////////////
Why i see different result, takeRow and takeItem (with scan by all
column), of a QStandardItemModel class, different functions ?
qt-win-opensource-src-4.3.1-snapshot-20070711
--
[ signature omitted ]