QTreeWidget expand/collapse indicator issue
-
Environment:
Windows 7 x 64, Visual Studio 2010, Qt 4.8.2Problem:
The expand/collapse indicator on the QTeeWidget colors itself after painting a QTreeWidgetItem.
This is something that is very difficult to explain and is better understood with an example.
I have created a visul studio 2010 solution that demonstrates the problem and can be found here.
"QTreeWidgetIssue.zip":http://www.codedconsulting.com/temp
Its too much code to post here.Procedure
- Open the VS .sln file.
- Build and execute the program.
- On the GUI navigate the tree to see what is there. Its a demo app, so not much just a tree with 5 top level items with 3 sub items per top item.
- Press the Do Border button. You will see that WordGroup1 and VarGroup1 are "bordered green". This is exactly what I want.
It signifies that something has changes for thess groupings.
But also notice that the expand/collapse indicators for the WordGroups below the "bordered" WordGroup1 are colored,
unlike the normal expand/collapse indicators above the "bordered" WordGroup1. - Close the application, It crashes but who cares this is just a demo app.
- Open the main.cpp file comment out lines 11 and 12.
QCleanlooksStyle* pStyle = new QCleanlooksStyle();
QApplication::setStyle( GetSubclassStyleForBaseStyle( pStyle ) ); - Build and execute the program.
- Press the Do Border button. This time the expand/collapse indicators are not colored.
Unfortunately I require the QCleanlookStyle for other things, so I cannot just get rid of it.
I would like to know if there is a way to modify the application, maybe in the CStyledTreeItemDelegate::paint() to solve or work around this issue.
Any ideas are greatly appreciated.Thank you,
Brian Holland -
I was actually able to solve this with some simple CSS. I added the following CSS to the QTreeWidget in the .ui file, after adding a couple images to the project and adding those images to the .qrc.
@QTreeView::branch:has-children:!has-siblings:closed, QTreeView::branch:closed:has-children:has-siblings
{
image: url(:/Images/tree-expand);
}
QTreeView::branch:open:has-children:!has-siblings, QTreeView::branch:open:has-children:has-siblings
{
image: url(:/Images/tree-collapse);
}@