How to customize movable header shadow
-
Hello,
In my application I have reimplemented QHeaderView in order to design a 45 degree angled header for a table which (after a lot of struggles) works quite well, and it looks like this:
The only issue I have with it is something I haven't been able to find anywhere. Whenever I drag a column, the 'shadow' that moves with the mouse still remains the same default header section design. Here is a picture (I am referring to the gray rectangle):
I have no idea what kind of component/element that is, and how to change it. Qt documentation tells me nothing, as far as I read...
I am also using PyQt 6.Any ideas would be very appreciated. Thank you.
-
The pixmap is created inside QAbstractItemViewPrivate::renderToPixmap() by calling the delegate for each index. So provide a custom item delegate where paint() returns your pixmap
-
-
@Christian-Ehrlicher It seems like QHeaderView does not support setItemDelegate.
From Qt docs: Note: Each header renders the data for each section itself, and does not rely on a delegate. As a result, calling a header’s setItemDelegate() function will have no effect.What am I missing? Right now I am reimplementing paintEvent to change the header appearance. Can I do something there?
-
You're right - I took the wrong place. The pixmap is created via QHeaderView::paintSection() (via QHeaderViewPrivate::setupSectionIndicator() and QHeaderView::mousePressEvent()) which is virtual so you should be able to override it.