How to change TableView row colors which is using QSqlQueryModel
-
Hi,
I use Tableview like below;QSqlQueryModel *modelDosya; modelDosya->setQuery("SELECT sira_no, dosya_ad, dosya_yol FROM dosyalar " "WHERE kaynak_sn = " + index.sibling(index.row(), 0).data().toString() + " AND prog_kod = 59 " "ORDER BY sira_no;",baglanti::mdb()); ui->tVDosya->setModel(modelDosya); //Not working! modelDosya->setData(modelDosya->index(1,2),QBrush(Qt::red), Qt::BackgroundRole);
But color is not working. I tryed
QStandardItemModel *modelDetay;And color is working well.
Any solution for "QSqlQueryModel "
Regards,
Mucip:) -
Hi,
Either subclass QSqlQueryModel and handle that role yourself or use QIdentityProxyModel and handle the color in that model rather than the SQL model.
-
Hi,
Either subclass QSqlQueryModel and handle that role yourself or use QIdentityProxyModel and handle the color in that model rather than the SQL model.
-
What did you not understand ?
-
Should you ? That's up to you to decide.
Because the method name is setSourceModel
-
Should you ? That's up to you to decide.
Because the method name is setSourceModel