backgournd color only takes effect on items
-
Hello, I want to set diffenrent background color for different rows. It seems the background color doesn't take effect on branch icon and indentation area at left side,while there are no such issues from the similar images from google. The test environment is windows11 qt 5.15.4 and visual studio2022 with qt extension.
Here is the test code:QTreeView* treeView = new QTreeView(this); QStandardItemModel* model = new QStandardItemModel(treeView); QStandardItem* item1 = new QStandardItem("node1"); QStandardItem* item2 = new QStandardItem("node2"); treeView->setStyleSheet(styleSheet); treeView->setModel(model); model->appendRow(item1); item1->appendRow(item2); treeView->setAlternatingRowColors(true); QString styleSheet = "QTreeView{alternate-background-color: #ff0000;}";
Anyone can help? -
Hello, I want to set diffenrent background color for different rows. It seems the background color doesn't take effect on branch icon and indentation area at left side,while there are no such issues from the similar images from google. The test environment is windows11 qt 5.15.4 and visual studio2022 with qt extension.
Here is the test code:QTreeView* treeView = new QTreeView(this); QStandardItemModel* model = new QStandardItemModel(treeView); QStandardItem* item1 = new QStandardItem("node1"); QStandardItem* item2 = new QStandardItem("node2"); treeView->setStyleSheet(styleSheet); treeView->setModel(model); model->appendRow(item1); item1->appendRow(item2); treeView->setAlternatingRowColors(true); QString styleSheet = "QTreeView{alternate-background-color: #ff0000;}";
Anyone can help? -
@m-f-d
How does it look if you create multiple items on the same level of your tree? Do they have alternating colors then?
It's a style thing. See SH_ItemView_ShowDecorationSelected. For fusion it's enabled, for windows only when it is a QListView
-
@m-f-d
How does it look if you create multiple items on the same level of your tree? Do they have alternating colors then?
-
@m-f-d said in backgournd color only takes effect on items:
but only for items, branch icons are still white background.
Ignoring me helps for sure...