QTableview Change Row Color

  • Hallo, I am new in Qt and C++, and I have a question:

    I have Tableview wich is set to QSqlQueryModel. MySql Table structure looks like this:

    ID | VALUE | NAME|
    1 _____1 ___Tom
    2 _____0 ___Mark
    3 _____0 ___Rita
    4 _____1 ___Sam

    @this->model1 = new QSqlQueryModel();
    model1->setQuery("SELECT ID, value, Name FROM DB_Table ");

    I want to change color of the rows there VALUE = 1, for example make it red.

    I can't get it how can i do it ? I even can't find a way to manualy change color o one row for example:

    Tableview->Row(1)->SetColor(QColor); // Can I do something similar ?

    Sory for my English.

    Thank you.

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    If you don't change your data you can use a "QIdentityProxyModel":http://qt-project.org/doc/qt-5/qidentityproxymodel.html

    Hope it helps

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.