[PySide] Can't override paintEvent on QTableWidget
frank at ohufx.com
Thu Sep 1 06:03:45 CEST 2022
Brilliant, that not only works but makes perfect sense :)
On Tue, Aug 30, 2022 at 7:38 PM Cristián Maureira-Fredes <
Cristian.Maureira-Fredes at qt.io> wrote:
> On 8/30/22 07:48, Frank Rueter wrote:
> > Hi all,
> Hey there,
> > I am trying to override the paintEvent in a QTableWidget to draw a
> > custom progressbar into the table area until the table data is loaded. I
> > have done this with other widgets in the past but the table widget won't
> > let me do this.
> > I am getting these errors:
> > QWidget::paintEngine: Should no longer be called
> > QPainter::begin: Paint device returned engine == 0, type: 1
> > QPainter::setBrush: Painter not active
> > Here is a simple code snippet for testing:
> > https://gist.github.com/frueter/a5b722926a847c291d1472a6fd145dbf
> > <https://gist.github.com/frueter/a5b722926a847c291d1472a6fd145dbf>
> > When I inherit from QWidget it works fine.
> > Is this sort of thing not possible with a QTableWidget?
> It's because QTableWidget is a subclass of QTableView (and that's one
> from QAbstractScrollArea),
> and AFAIK you need to open the painter based on the base viewport.
> and there you can see the hint to use the viewport.
> In your code,
> just replace:
> painter = QtGui.QPainter(self)
> painter = QtGui.QPainter(self.viewport())
> and it should work. At least locally, I can see the gradient.
> > Cheers,
> > frank
> Dr. Cristián Maureira-Fredes
> Senior R&D Manager
> The Qt Company GmbH
> Erich-Thilo-Str. 10
> D-12489 Berlin
> Geschäftsführer: Mika Pälsi,
> Juha Varelius, Jouni Lintunen
> Sitz der Gesellschaft: Berlin,
> Registergericht: Amtsgericht
> Charlottenburg, HRB 144331 B
> PySide mailing list
> PySide at qt-project.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the PySide