[Qt-interest] Problem with QPainter in paintEvent
Chandru...
sekarwagmare at gmail.com
Wed Jul 29 08:33:52 CEST 2009
*QPainter::begin: A paint device can only be painted by one painter at a
> time.*
this error will occurs
first
two times u try to paint using painter->begin() in paintEvent
second
if u use QGraphicsView
if u try to add a QWiget to a QGraphicsView that is already embed to another
graphicsView it will spit this error
On Wed, Jul 29, 2009 at 11:54 AM, Samuel Rødal <sroedal at trolltech.com>wrote:
> BaH wrote:
> > Hi list,
> >
> > I'm in the process of writing a Qt language binding for BlitzMax, which
> > appeared to be going very well. Current testing is on OS X, latest Qt
> > source release, cocoa build. But I appear to have hit a wall when it
> > comes to using a QPainter inside a paintEvent of a subclassed QWidget.
> >
> > Everything in the code looks fine, but I get this output on the console :
> >
> > QPainter::begin: A paint device can only be painted by one painter at a
> > time.
> >
> >
> > So, I assume I've done something wrong somewhere...
> >
> > Here's some of the relevant code :
> >
> >
> > class MaxQWidget : public QWidget
> >
> > {
> >
> > Q_OBJECT
> >
> >
> > public:
> >
> > MaxQWidget(BBObject * handle, QWidget * parent, Qt::WindowFlags flags);
> >
> > ~MaxQWidget();
> >
> >
> > protected:
> >
> > void paintEvent(QPaintEvent * event);
> >
> > private:
> >
> > BBObject * maxHandle;
> >
> > };
> >
> >
> >
> > and paintEvent() is implemented as this :
> >
> >
> > void MaxQWidget::paintEvent(QPaintEvent * event) {
> >
> > _qt_qwidget_QWidget__OnPaintEvent(maxHandle, event);
> >
> > }
> >
> >
> >
> > which simply passes the event up into the BlitzMax framework, causing
> > the BlitzMax paintEvent() method to be called.
> > In this method, I create a new instance of a QPainter, of which the glue
> > looks like this :
> >
> >
> > QPainter * bmx_qt_qpainter_create() {
> >
> > return new QPainter();
> >
> > }
> >
> >
> >
> > I then call painter->begin() passing in the QWidget pointer.
> > At this point, the error is output on the console.
> > begin() returns 0, which is expected, due to the error.
> >
> > I can't see anything obvious that I may have missed.
> >
> > paintEvent() is called every tick of a QTimer, and anytime I resize the
> > window, so there's nothing wrong there. But for some reason, the QWidget
> > appears to already be painting when my paintEvent() is called.
> >
> > Have I completely overlooked something?
> > I've basically implemented a direct port of the analogclock example in
> > BlitzMax, which is pretty much line-for-line the same as the C++ example.
> >
> > Any guidance would be greatly appreciated.
> >
> > cheers,
> >
> > Brucey
>
> Make sure you call update() on the widget instead of calling the
> paintEvent() directly.
>
> --
> Samuel
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
--
WAGMARE
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090729/ac593a52/attachment.html
More information about the Qt-interest-old
mailing list