I think that works because QScrollArea's events are actually remapped for the viewport anyway.
Tony > -----Original Message----- > From: interest-bounces+tony=rightsoft.com...@qt-project.org > [mailto:interest-bounces+tony=rightsoft.com...@qt-project.org] On Behalf > Of igor.mironc...@gmail.com > Sent: Thursday, 27 March 2014 8:35 PM > To: Konstantin Tokarev; interest@qt-project.org > Subject: Re: [Interest] Drawing on viewport > > 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.mironc...@gmail.com ; interest@qt-project.org > Subject: Re: [Interest] Drawing on viewport > > > 27.03.2014, 12:28, "igor.mironc...@gmail.com" <igor.mironc...@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 > > _______________________________________________ > Interest mailing list > Interest@qt-project.org > http://lists.qt-project.org/mailman/listinfo/interest _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest