[Qt-interest] QGraphicsEffect drawing

Anton Chernov mechernov at gmail.com
Sat Jul 16 09:05:02 CEST 2011


class Q_GUI_EXPORT QGraphicsEffect : public QObject
{
    Q_OBJECT
    Q_FLAGS(ChangeFlags)
    Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY
enabledChanged)
public:
[...]
friend class QGraphicsItem;
friend class QGraphicsItemPrivate;
friend class QGraphicsScenePrivate;
friend class QWidget;
friend class QWidgetPrivate;
[...]
}

it seems that only QGraphicsScenePrivate has access to protected
effect members... if i reimplement ::render i still would need to
render the effects...

something is missing...

how does the actual source pixmap come to an effect? It seems that it
looks in the cache for a pixmap, but who and where renders this pixmap
to the cache?

2011/7/16 Malyushytsky, Alex <alex at wai.com>:
> How many subclasses of QGraphicsScene you have?
> Create a single subclass MyCraphicsScene which would implement flag and always derive from it instead of QGraphicsScene.
>
> Alex
>
> -----Original Message-----
> From: Anton Chernov [mailto:mechernov at gmail.com]
> Sent: Friday, July 15, 2011 1:26 PM
> To: Malyushytsky, Alex
> Cc: qt-interest at trolltech.com
> Subject: Re: [Qt-interest] QGraphicsEffect drawing
>
> I want avoid this because i every class i would have to have such a
> flag - that's miserable :) Bad c++ is miserable too, but takes less
> place in code :)
>
> 2011/7/15 Malyushytsky, Alex <alex at wai.com>:
>> QGraphicsEffect is base class for the for graphics effects.
>>
>> This probably means that when you set effect you do not create instance of QGraphicsEffect, but
>> QGraphicsBlurEffect, QGraphicsColorizeEffect, QGraphicsDropShadowEffect, or QGraphicsOpacityEffect.
>>
>> So what you are trying to do below is illegal, cause none of the above classes are derived from
>> BadEffectAccessor.
>>
>> I can't give you direct answer on your question, but I don't think you need id.
>>
>> void QGraphicsScene::render calls
>>   virtual void drawItems(...) to draw items.
>>
>> All you need to make standard render work the way you want is override so it skips items you don't want to draw ( set flag before calling it for example ).
>>
>>
>> Regards,
>>  Alex
>>
>>
>> -----Original Message-----
>> From: qt-interest-bounces+alex=wai.com at qt.nokia.com [mailto:qt-interest-bounces+alex=wai.com at qt.nokia.com] On Behalf Of Anton Chernov
>> Sent: Friday, July 15, 2011 12:47 AM
>> To: qt-interest at trolltech.com
>> Subject: [Qt-interest] QGraphicsEffect drawing
>>
>> Hi,
>>
>> I have a problem drawing QGraphicsEffects - a have a scene with lots
>> of items, but when rendering for print only particular items should be
>> drawn.
>> If i would call
>>
>> QGraphicsScene::render( ... )
>>
>> all will be drawn, so I use a custom renderer. Everything draws good
>> except the graphics effects - their
>>
>> draw( QPainter* painter )
>>
>> is protected.
>>
>> class BadEffectAccessor : public QGraphicsEffect
>> {
>>   public:
>>      void publicDraw( QPainter* painter ) { draw( painter ); }
>> };
>>
>> [...]
>> if( text->graphicsEffect() ) {
>>   BadEffectAccessor* accessor = static_cast< BadEffectAccessor* >(
>> text->graphicsEffect() );
>>   accessor->publicDraw( painter );
>> }
>> [...]
>>
>> Does not help, nothing is drawn! How do I draw the effects?
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at qt.nokia.com
>> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>>
>>
>> ---------------------------------------------------------------------------------------------------
>> 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 qt.nokia.com
>> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>



More information about the Qt-interest-old mailing list