Stylesheet in QTreeWidget Change Arrow Images from .qrc
-
So I have my QTree widget exactly like I want it but I have one thing that I would like to do. The following code allows me to have white arrows on a black background as long as the .png files are in the build directory.
ui->treeWidgetProcs->setStyleSheet("QTreeView { background: black; color: white; }
QTreeView::branch { background: black; }
QTreeView::branch:closed:has-children:has-siblings { border-image: none; image: url(branch-closed.png); }
QTreeView::branch:open:has-children:has-siblings { border-image: none; image: url(branch-open.png); }");I also have the two .png files in the .qrc file that I have in my project that contains my icon however it doesn't work. There is no prefix assigned to any of the files.
ui->treeWidgetProcs->setStyleSheet("QTreeView { background: black; color: white; }
QTreeView::branch { background: black; }
QTreeView::branch:closed:has-children:has-siblings { border-image: none; image: url(:/branch-closed.png); }
QTreeView::branch:open:has-children:has-siblings { border-image: none; image: url(:/branch-open.png); }");Can anyone see what I am doing wrong or will this just not work? Thanks in Advance!
-
Make sure the path is correct by e.g. checking if the resource file exists with QFile::exists().
-
Yes the file does exist and I am getting my window Icon from the file and that is working fine. I checked and both of the png files are referenced in the qrc file. I looked at the .ui code for mainwindow and it specifies a
<iconset resource="icons.qrc">
where it loads my Icon. Do I need to specify a resource file to use in code somewhere before using the resources?
-
Hi,
Can you share the .qrc file content ?
-
@shathcock Did you really wrote
url(:/branch-closed.png);
and not by accident e.g.url( :/branch-closed.png );
or similar?
Please provide a minimal, compilable example. -
@Christian-Ehrlicher I'm positive I have tried it at least 10 times. I'll have to get a compilable example together I assume you mean a complete project. How should I include it in the forum I have never done that before and it will take me some time to get it together.