I have a QSqlTableModel, a QTableView and a QStyledItemDelegate.
I can find out the column name in paint() this way:
if( abstractmodel->inherits( "QSqlQueryModel"))
{
fieldname = rec.fieldName(col);
}
QString fieldname, tablename;
const QAbstractItemModel *abstractmodel = index.model();
if( abstractmodel->inherits( "QSqlQueryModel"))
{
QSqlQueryModel *model = (QSqlQueryModel *)abstractmodel;
QSqlRecord rec = model->record();
fieldname = rec.fieldName(col);
}
To copy to clipboard, switch view to plain text mode
Same if I use QSqlTableModel instead of for QSqlQueryModel. This part works.
But now I need to find out the tablename because when I use QSqlQueryModel I can join multiple tables and I can't identify a certain column only by the column name, I also need the table name...
Bookmarks