QSqlTableModel, how to show png images in table
Unsolved
General and Desktop
-
Hi,
I have :
QSqlTableModel *model = new QSqlTableModel (); model->setEditStrategy(QSqlTableModel::OnFieldChange); model->setTable("personel"); model->setEditStrategy(QSqlTableModel::OnManualSubmit); model->select(); model->setHeaderData(0, Qt::Horizontal, tr("name")); model->setHeaderData(1, Qt::Horizontal, tr("file")); model->setHeaderData(2, Qt::Horizontal, tr("image_png")); model->setHeaderData(3, Qt::Horizontal, tr("category")); QSqlQuery* query_new = new QSqlQuery(db); query_new->prepare("select * from personel"); query_new->exec(); model->select(); ui->sql_table_view->setModel(model);
it is showing the all texts field automatically.
How can I show image_png sqlite field in this table ?
,best
-
Hi
Do you mean you have a binary blob in the DB that is an image and you want to show that as an image ?
https://wiki.qt.io/How_to_Store_and_Retrieve_Image_on_SQLite -
@RahibeMeryem said in QSqlTableModel, how to show png images in table:
QSqlTableModel
QSqlTableModel . what I need to show images from Sqlite query.
-
Derive from QSqlTableModel, overwrite data() for Qt::DecorationRole and return the decoded image in there.
-
Or use a delegate like here: https://forum.qt.io/topic/94494/qsqlquerymodel-and-qpixmap-s-alignment
In that case
pixmapY
is static but nothing stops you reading it fromindex.data()