[Qt-interest] What is wrong on QPainter?

Oliver.Knoll at comit.ch Oliver.Knoll at comit.ch
Wed May 13 14:05:52 CEST 2009


Stefanos Antaris wrote on Wednesday, May 13, 2009 1:59 PM:

> ...
> [code] painter =
> new QPainter(this); 

What is "this"? A QWidget? QGLWidget? QPrinter?

> ...
>     QPainterPath path;
>     path.moveTo(80,320);
>     path.cubicTo(200,80,320,80,480,320);
> 
>     painter->setPen(QPen(Qt::black,8));
>     painter->drawPath(path);
> 
> [/code]

When exactly is this code called? 

Given the fact that you do *not* deallocate your painter anywhere in your example code this gives me the impression that you try to execute this code in some c'tor instead! (which would not work!) And if it was allocated within QWidget::paintEvent() (the proper place to use a painter) then you would have a huge memory leak (but you should still be able to "see" your drawn stuff then).

What is it exactly what you get? Blank background? Uups, and just to make sure: you don't happen to set your background colour to black as well, now do you? Sorry, could not resist to ask this question ;)

Cheers, oliver
-- 
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22



More information about the Qt-interest-old mailing list