Details
-
Bug
-
Resolution: Incomplete
-
P2: Important
-
None
-
5.15.2
-
None
Description
#include "MainWindow.h" #include <QApplication> #include <QFileSystemModel> #include <QTreeView> int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; // Create a file system model QFileSystemModel model; model.setRootPath(""); // Create the QTreeView instance and set up the model QTreeView treeView(&w); treeView.setModel(&model); treeView.setRootIndex(model.index("")); // Set the root directory // Define the QSS style directly in code QString qss = "\ QTreeView {\ border: none;\ border-top: 1px solid #14000000;\ padding: 4px;\ show-decoration-selected: 1;\ }\ QTreeView::item {\ outline: none;\ color: #101010;\ }\ QTreeView::item:hover, QTreeView::branch:hover {\ background: #19203030;\ }\ QTreeView::item:selected, QTreeView::branch:selected {\ background: #1900FFFF;\ outline: none;\ }"; treeView.setStyleSheet(qss); // apply style w.setCentralWidget(&treeView); w.show(); return a.exec(); }
If you use the above code and click on a row, you will notice that the branch part is displayed in dark blue. If you replace "#1900FFFF" with a non-transparent color like "#E6FFFF", you won't encounter this issue.