[Qt-interest] [Qt-Interest] Painting outside paintEvent in QT4.5 : Widget painting can only begin as a result of a paintEvent

Malyushytsky, Alex alex at wai.com
Wed Jun 3 02:41:13 CEST 2009


>> Use QImage, QPicture is designed for saving the commands to a file...

I would not say so.
According to my impression QPicture is designed to be resolution independent.
Since I have not finished my test project yet, the only source I can refer is  QT documentation:
" i.e. a QPicture can be displayed on different devices (for example svg, pdf, ps, printer and screen) looking the same. This is, for instance, needed for WYSIWYG print preview."

That what makes it different, no an ability to store commands into the file.
This is the same as you don't have to save QImage to the file if you don't need to.

Also painting QPixmap supposed to be faster than QImage, so if you don't need to be able to paint when window is absent I would stay with QPixmap.

Regards,
   Alex





-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Scott Aron Bloom
Sent: Monday, June 01, 2009 7:49 PM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] [Qt-Interest] Painting outside paintEvent in QT4.5 : Widget painting can only begin as a result of a paintEvent

Use QImage, QPicture is designed for saving the commands to a file...

QImage is designed for exactly what you are trying to do...

QImage img;
QPainter painter( &img )

Do the painting, then call update()

Scott

> -----Original Message-----
> From: qt-interest-bounces at trolltech.com [mailto:qt-interest-
> bounces at trolltech.com] On Behalf Of Malyushytsky, Alex
> Sent: Monday, June 01, 2009 7:21 PM
> To: qt-interest at trolltech.com
> Subject: Re: [Qt-interest] [Qt-Interest] Painting outside paintEvent in QT4.5
> : Widget painting can only begin as a result of a paintEvent
>
> According to how I see it:
>
> Approach A (simplest)
> ------------------------------------------------------------------
> Instead of painting to the widget, paint to the QPixmap or QImage.
> Update the widget when painting done.
>
> + minimum changes to the paining code.
> - sometimes update of the whole widget from image is inefficient and it might
> be not that easy to implement it efficiently.
>    And things got worse when you like to see evolution of the drawing on the
> screen instead of the result.
>
>
> Approach B (never tried, but it looks promising, if I don't make any mistake
> about it functionality)
> ------------------------------------------------------------------
> Paint to QPicture, store QPicture object(s).
> Call update when required, use QPicture object to draw in the paint event.
>
> I can't recommend it, cause I never tried, but it seems more powerful.
>
>
> Best regards,
>
> Alex
>
>
>
>
> -----Original Message-----
> From: qt-interest-bounces at trolltech.com [mailto:qt-interest-
> bounces at trolltech.com] On Behalf Of Thiago Macieira
> Sent: Saturday, May 30, 2009 2:52 PM
> To: qt-interest at trolltech.com
> Subject: Re: [Qt-interest] [Qt-Interest] Painting outside paintEvent in QT4.5
> : Widget painting can only begin as a result of a paintEvent
>
> shivam priyadarshi wrote:
> >I have this kind of code structure at various places in application. I
> >have tight schedule, it will be great help if you can help me with make
> >it work with QT4.5 with painting outside paintEvent.
>
> You have to refactor your code so that you paint only inside the paintEvent.
> --
> Thiago Macieira - thiago.macieira (AT) nokia.com
>   Senior Product Manager - Nokia, Qt Software
>       Sandakerveien 116, NO-0402 Oslo, Norway
>
>
> ------------------------------------------------------------------------------
> ---------------------
> Weidlinger Associates, Inc. made the following annotations.
>
> “This message and any attachments are solely for the intended recipient and
> may contain confidential or privileged information. If you are not the
> intended recipient, any disclosure, copying, use, or distribution of the
> information included in this message and any attachments is prohibited. If you
> have received this communication in error, please notify us by reply e-mail
> and immediately and permanently delete this message and any attachments. Thank
> you.”
>
> “Please consider our environment before printing this email.”
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest

_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest

“This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you.”




More information about the Qt-interest-old mailing list