Qt: QTableWidget/QTableView alternating row colors in full viewport
qt, user-interface
Solution
Why don't you use Qt QSS for this? It working just fine. Have a look here : http://www.qtcentre.org/threads/42211-QTableWidget-alternating-background-color?p=263046#post263046
myTable->setAlternatingRowColors(true);
myTable->setStyleSheet("alternate-background-color: yellow;background-color: red;");
Problem
I have a QTableView containing data rows from a database. However, setting setAlternatingRowColors(true) only alternates row colors that has data - the rest of the table is just white, which is not the behaviour you'd expect (look in the bookmark list of any browser, for example - empty rows has alternating colors). Does anyone know a workarund or an alternative to the table views supplied by Qt? I've fiddled with stylesheets and item delegates, same result.