Qt World Summit: Register Today!

QTreeWidget Branch Arrow Disappears

  • I have a QTreeWidget that is working well but I have a small problem. I needed to make some of the items different colors which is working fine however they are very hard to read against the default white background. I changed the background color of the entire widget to black and everything looks good but realizing that the branch column was trying to display a black > against a black background wouldn't work I changed it to yellow. Now can't see the > at all only the yellow background. Any help or suggestions would be greatly appreciated.

  • @shathcock Ok I just figured this one out. I found some arrow .png files online and copied them into the build directory and included them in the css declaration and it works....

    Here is the code in case anyone else is looking at this.

    ui->treeWidgetProcs->setStyleSheet("QTreeView { background: black; color: white; }
    QTreeView::branch { background: yellow; }
    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); }");

Log in to reply