[Interest] Drawing on viewport

igor.mironchik at gmail.com igor.mironchik at gmail.com
Thu Mar 27 10:35:04 CET 2014


Ok.

But it works in QTextEdit.

Look:

void QTextEdit::paintEvent(QPaintEvent *e)
{
    Q_D(QTextEdit);
    QPainter p(d->viewport);
    d->paint(&p, e);
}

-----Original Message----- 
From: Konstantin Tokarev
Sent: Thursday, March 27, 2014 10:32 AM
To: igor.mironchik at gmail.com ; interest at qt-project.org
Subject: Re: [Interest] Drawing on viewport


27.03.2014, 12:28, "igor.mironchik at gmail.com" <igor.mironchik at gmail.com>:
> Hi.
>
> I’m working on TextEdit widget for QtMWidgets library.
>
> TextEdit is a subclass of ScrollArea that derived from AbstractScrollArea. 
> AbstractScrollArea is implemented like QAbstractScrollArea and has 
> viewport as child widget.
>
> In TextEdit’s paintEvent I want to draw directly on viewport. And I 
> initialize QPainter with:
>
> QPainter p( viewport() );
>
> But I receive folowing warning:
>
> QWidget::paintEngine: Should no longer be called
>
> QPainter::begin: Paint device returned engine == 0, type: 1
>
> QPainter::setPen: Painter not active
>
> and nothing draws.
>
> What am I doing wrong?

One does not simply paint on the other widget.


-- 
Regards,
Konstantin 




More information about the Interest mailing list