I use QTableWidget to insert data when it is sorting, there has a problem i can't. For example:
QtTest::QtTest(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
ui.tableWidget->setSortingEnabled(true);
ui.tableWidget->sortByColumn(0, Qt::AscendingOrder);
}
void QtTest::on_pushButton_clicked()
{
static int i = 1;
ui.tableWidget->insertRow(0);
ui.tableWidget->setItem(0, 0, new QTableWidgetItem(tr("a%1").arg(i)));
ui.tableWidget->setItem(0, 1, new QTableWidgetItem(tr("b%1").arg(i+1)));
i++;
}
then click pushbutton, i can't add data to the row i want, Is there a elegant way to solve it?