[SOLVED]QTreeWidget setStyleSheet problem
-
wrote on 17 Aug 2015, 07:15 last edited by tony_tang
I want to set the selected QTreeWidgetItem to a custom color, using the code below:
setStyleSheet("QTreeWidget::item::selected{background-color: rgb(50, 50, 50)}");
but it does not work very well: there is some other color on the left part of the QTreeWidgetItem.
Is there any way to solve this? -
Hi
A QTreeWidget will show an arrow for items with children. to the left.
Is it that area you area talking about ?Its not considered part of the item and will have the color for
background-color for the whole TreeWidget.If you do not need a tree view, then maybe just use a listwidget where the item
will take up all row. ? -
Hi
A QTreeWidget will show an arrow for items with children. to the left.
Is it that area you area talking about ?Its not considered part of the item and will have the color for
background-color for the whole TreeWidget.If you do not need a tree view, then maybe just use a listwidget where the item
will take up all row. ? -
Hi
A QTreeWidget will show an arrow for items with children. to the left.
Is it that area you area talking about ?Its not considered part of the item and will have the color for
background-color for the whole TreeWidget.If you do not need a tree view, then maybe just use a listwidget where the item
will take up all row. ? -
@tony_tang
That area can be styled with QTreeView::branch
have a look at
https://forum.qt.io/topic/8034/changing-the-color-of-qtreeview-s-branches/2 -
@tony_tang
That area can be styled with QTreeView::branch
have a look at
https://forum.qt.io/topic/8034/changing-the-color-of-qtreeview-s-branches/2 -
I want to set the selected QTreeWidgetItem to a custom color, using the code below:
setStyleSheet("QTreeWidget::item::selected{background-color: rgb(50, 50, 50)}");
but it does not work very well: there is some other color on the left part of the QTreeWidgetItem.
Is there any way to solve this?wrote on 17 Aug 2015, 09:31 last edited by tony_tang@tony_tang
I solved the problem using this method:QPalette pal = palette();
pal.setColor(QPalette::ColorRole::Highlight, QColor(50, 50, 50));
setPalette(pal); -
@tony_tang
I solved the problem using this method:QPalette pal = palette();
pal.setColor(QPalette::ColorRole::Highlight, QColor(50, 50, 50));
setPalette(pal);@tony_tang said:
Super!
Thank you for reporting back.
1/8