Qt-interest Archive, May 2007
More QDataWidgetMapper problems
Message 1 in thread
Hi,
I'm wondering if anyone can tell me how to insert a row into a
QSqlTableModel that is attached to a widget mapper. The mapper's
currentRow() returns -1 after doing an addRow() to the table model and
the mapper's index cannot be changed. How is it supposed to work?
Thanks,
John
--
[ signature omitted ]
Message 2 in thread
I just answered my own question using the "C++ GUI Programming With Qt4"
book.
Here's a summary for anyone else who cares:
void MyDataClass::MyDataClass(void)
{
connect(model, SIGNAL(primeInsert(int, QSqlRecord &)), this,
SLOT(primeInsert(int, QSqlRecord &)));
}
void MyDataClass::insertRow(void)
{
model->setTable("Parts");
model->insertRows(0, 1);
}
void MyDataClass::primeInsert(int row, QSqlRecord &record)
{
mapper->setCurrentIndex(row);
}
John Voltz wrote:
> Hi,
>
> I'm wondering if anyone can tell me how to insert a row into a
> QSqlTableModel that is attached to a widget mapper. The mapper's
> currentRow() returns -1 after doing an addRow() to the table model and
> the mapper's index cannot be changed. How is it supposed to work?
>
> Thanks,
>
> John
--
[ signature omitted ]