Hello Again!
Just wanted to give a quick update; I chose to implement a custom model, subclassing naturally QAbstractTableModel, and since it's read-only, I've had just four methods; rowcount, colmuncount, headerData, but the problem is with Data() method, here's what I did:
{
QSqlQuery q
("select name from employee where id=3");
while (q.next()) {
name = resultat.toString();
}
switch( role )
{
case Qt::DisplayRole:
if (index.column()==1 && index.row()==2)
return name;
default:
}
}
QVariant CustomModel::data( const QModelIndex &index, int role ) const
{
QString name;
QSqlQuery q("select name from employee where id=3");
while (q.next()) {
QVariant resultat = q.value(0);
name = resultat.toString();
}
switch( role )
{
case Qt::DisplayRole:
if (index.column()==1 && index.row()==2)
return name;
default:
return QVariant();
}
}
To copy to clipboard, switch view to plain text mode
This works as I can display the data right where I want it to, but I'm not sure if this is the right way to go, any opinions?
Thanks
Bookmarks