Important: Please read the Qt Code of Conduct -

[Solved] How to set color to a tableview values from the database

  • @ Log cnn;
    QSqlQueryModel *modal=new QSqlQueryModel();
    QSqlQuery *qry=new QSqlQuery(cnn.mydb);
    qry->prepare("select *from AccessLog");
    With this method i can set a QSQlQueryModels to my QTableviews.How i can set color to each row in tableview.

  • To achieve alternating colours for the rows you may set


    then set the colours of Base and AlternateBase in the palette.

  • Thanks.....

  • Does that mean that you figured out the problem? If so, Please add [solved] to the topic so everyone can see that this problem is solved. You can do that by editing your first post.

  • And also one method for this solution,In QtCreator UI Forms select the tablview control and change the property of styleSheet. It include the various options such as color,background color,border color etc.

Log in to reply