4

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:

enter image description here

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:

enter image description here

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!

SexyBeast
  • 7,913
  • 28
  • 108
  • 196
  • I can't reproduce this. What is your version of OS X and Qt? It's supposed to work, so if some OS X + Qt combination doesn't support it, it's a bug in Qt and you can't do anything about it other than fixing Qt, I think. – Kuba hasn't forgotten Monica Feb 15 '15 at 20:09
  • Qt 5.3 32 bit, OS X 10.10 Yosemite. If you hover over the scrollbar, the scrollbar will thicken, which is normal OS X behavior. Then you will see this thing.. – SexyBeast Feb 16 '15 at 04:32
  • OK, this is a Qt bug then and you should report it. Make sure to search for bug reports first, it could be already reported. – Kuba hasn't forgotten Monica Feb 16 '15 at 14:02
  • Okay, will do then. In the meantime, I have modified my problem to something different, but intractable still, so will update soon. – SexyBeast Feb 16 '15 at 17:37

0 Answers0