Important: Please read the Qt Code of Conduct -

QTreeWidget border radius toggles visibility during scrolling when set alternating row colors

  • I am trying to design a QTreeWidget with border-radius. The problem sets in when I assign alternate row colors to it. When I don't, it works fine, and the border-radius around the widget is always visible during scrolling. However, when I scroll with the alternate row colors set, during even numbered rows being at the top and bottom, the border-radius remains as expected, while during odd numbered ones, they are eclipsed, with the look and feel of a widget with no border-radius. Here's what it looks like when the grey colored rows are at the top and bottom:

    ! with border-radius)!

    And after you scroll one unit, or odd number of units, so that the white colored rows are at the ends, this is what it looks like:

    ! without border radius)!

    How do I fix this? And in Windows, because the scrollbars are differently styled, the right side will always have the border radius eclipsed due to the scroll pane. Is there a way to make it behave just like the Mac scrollbar?

    My style sheet is pretty minimal:

    @#myTreeWidget {background-color: #C2C7CB; border-radius: 8px; }@

    I set the width of the rows through a delegate:

    class ItemDelegate : public QItemDelegate
    QSize sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const
    return QSize(240,25);

    ItemDelegate *delegate = new ItemDelegate();

    myTreeWidget = new QTreeWidget(this);
    myTreeWidget->setGeometry(QRect(20, 10, 240, 375));

    I just observed a weird thing. If I remove the background color from the widget, the border radius completely disappears. Not visible under any circumstance!

  • Lifetime Qt Champion


    Looks like it could be a bug. You should check the "bug report system": to see if it's something known

Log in to reply