I have a QTableView showing rows of a database table. In this table, I have a column called a data type, and I have icon images for each type. How to add these icons before each data type?
Here is part of my code at the request of justanothercoder.
QString msgQueryString = "select MESSAGE_ID, DATA_TYPE from SER_MESSAGES where MESSAGE_ID > 500 "; serendibMsgTableModel->setQuery(msgQueryString, *database); serendibMsgTableModel->setHeaderData(0, Qt::Horizontal, tr("Message ID")); serendibMsgTableModel->setHeaderData(1, Qt::Horizontal, tr("Data Type")); serendibMsgProxyModel->setSourceModel(serendibMsgTableModel); serendibMsgView->setModel(serendibMsgProxyModel);
"serendibMsgTableModel" is the QSqlQueryModel , and "serendibMsgProxyModel" is the custom QSortFilterProxyModel . "serendibMsgView" is a QTableView I need the icons that will be displayed in the "Data Type" column.
Hope this helps you answer.
source share