waterd
waterd

Reputation: 651

Why QTableView's selection-background-color doesn't fucntion as expected in Qt4.8.6 via qss?

My developing qt version is Qt4.7.0 and running qt versin is Qt4.8.6. The OS is identical and that is Ubuntu Kylin 14.04.

There is an weird thing that tableView->setStyleSheet(QString("QTabelView{selection-background-color:transparent;}")); works well in Qt4.7.0 but not in Qt4.8.6.

In Qt4.8.6 the default selection-background-color is an gray-like color, but when I set selection-ground-color to transparent the real selection-background-color becomes white other than transparent as shown in the below image. It obviously doesn't work as expected.

The result is beyond expection

In Qt4.7.0 all is right.

The entire styleSheet is QString("QTableView{border-image:url(%1); padding-left:1px; padding-top:153px; background-color:transparent; selection-background-color:transparent;} QTableView::item {border-left: 10px solid transparent;}") .arg(g_appPath + QString("/data/image_comm/cabinetV5/5master.png")).

What's wrong with my styleSheet string? Are there other ways to achieve my goal that making QTableView's selction cell's background transparent? Any help is appreciated.

Upvotes: 0

Views: 1166

Answers (1)

Ryan
Ryan

Reputation: 403

Try another selector like QTableView::item:selected{ background:.........; }, which works fine for me.

Upvotes: 0

Related Questions