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:

    !http://i.stack.imgur.com/rhQVA.png(Image 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:

    !http://i.stack.imgur.com/jhvwJ.png(Image 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
    {
    public:
    ItemDelegate()
    {}
    QSize sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const
    {
    return QSize(240,25);
    }
    };

    ItemDelegate *delegate = new ItemDelegate();

    myTreeWidget = new QTreeWidget(this);
    myTreeWidget->setObjectName(QString::fromUtf8("myTreeWidget"));
    myTreeWidget->setAttribute(Qt::WA_MacShowFocusRect,false);
    myTreeWidget->setGeometry(QRect(20, 10, 240, 375));
    myTreeWidget->headerItem()->setHidden(true);
    myTreeWidget->setItemDelegate(delegate);
    myTreeWidget->setAlternatingRowColors(true);
    @

    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

    Hi,

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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.