[Qt-interest] What is wrong on QPainter?
Stefanos Antaris
santaris at csd.auth.gr
Wed May 13 22:23:06 CEST 2009
qt-interest-request at trolltech.com wrote:
> Send Qt-interest mailing list submissions to
> qt-interest at trolltech.com
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://lists.trolltech.com/mailman/listinfo/qt-interest
> or, via email, send a message with subject or body 'help' to
> qt-interest-request at trolltech.com
>
> You can reach the person managing the list at
> qt-interest-owner at trolltech.com
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Qt-interest digest..."
>
>
> Today's Topics:
>
> 1. What is wrong on QPainter? (Stefanos Antaris)
> 2. Re: What is wrong on QPainter? (Oliver.Knoll at comit.ch)
> 3. Re: What is wrong on QPainter? (Andre Haupt)
> 4. Cleartype in QGraphicsScene with QGLWidget as viewport
> (Dennis Kehrig)
> 5. Re: What is wrong on QPainter? (Oliver.Knoll at comit.ch)
> 6. Re: getting inside the moc (Luca Ferrari)
> 7. Re: Cleartype in QGraphicsScene with QGLWidget as viewport
> (Samuel R?dal)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 13 May 2009 14:58:54 +0300
> From: Stefanos Antaris <santaris at csd.auth.gr>
> Subject: [Qt-interest] What is wrong on QPainter?
> To: qt-interest at trolltech.com
> Message-ID: <4A0AB5FE.5060206 at csd.auth.gr>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Hello i am reading on Prentice Hall C++ GUI Programming with Qt 4,
> Second Edition and i am reading about QPainter.I am just trying to make
> a simple app just to test it but something is going wrong.I am just
> trying to make a Bezier curve but it doesn't show me anything.Can anyone
> explain me?Here is my code on constructor.On the header file i just have
> this.QPainter* painter;
> [code]
> painter = new QPainter(this);
> painter->setRenderHint(QPainter::Antialiasing , true);
>
> QPainterPath path;
> path.moveTo(80,320);
> path.cubicTo(200,80,320,80,480,320);
>
> painter->setPen(QPen(Qt::black,8));
> painter->drawPath(path);
>
> [/code]
> The code is just a copy from the book.
>
>
> ------------------------------
>
> Message: 2
> Date: Wed, 13 May 2009 14:05:52 +0200
> From: <Oliver.Knoll at comit.ch>
> Subject: Re: [Qt-interest] What is wrong on QPainter?
> To: <qt-interest at trolltech.com>
> Message-ID:
> <C10F29AB06447B4881FC0DE1E302E2F2DEA22245 at sg000036.corproot.net>
> Content-Type: text/plain; charset="us-ascii"
>
> 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
>
I think i missed something.Where sould i override the paintEvent()?Can
anyone give me a simple .h and .cpp file just to understand how should i
use it?Sorry if i am asking you to give me a code but it is the first
time that i use something like the paint so it is difficult to me to
understand what you mean.Thanks in advance
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090513/7ff11c26/attachment.html
More information about the Qt-interest-old
mailing list