c++ - QTreeView, style each level differently -


my problem similar this question.

i have qtreeview connected model. possible style each level of tree in different way? need change background color of each line. different level have different background. expanded items have different color well.

i have tried http://doc.qt.io/qt-4.8/stylesheet-examples.html#customizing-qtreeview seems not possible using css. qproxystyle help? how used?

thank you, martin.

if using custom model (derived qabstractitemmodel or similar), can achieve returning appropriate value qabstractitemmodel::data() when data appearance role requested:

qvariant mymodel::data(const qmodelindex& index, int role) const {     switch(role)     {         case qt::displayrole:         {             ...             break;         }         case qt::backgroundrole:             return qcolor(qt::red);         case ...     }      return qvariant(); } 

using qstandardmodel can set data these roles qstandarditem::setdata().


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -