On Saturday 21 February 2009, Toussis Manolis wrote:
> I want to add some effect to an applet

what effect are you trying to achieve? because while you ask how to get a 
pixmap of your widget, depending on what effect you are trying to achieve that 
may not be what you actually want to be doing.

> QPixmap* m_oldPixmap;
>
> void PlasmaApplet::paintInterface(QPainter *p,
>         const QStyleOptionGraphicsItem *option, const QRect &contentsRect)
> {
>    .... do the painting....
>   and now:
>   store the current image of the applet for future use in a QPixmap/QImage
>  something like that:
>   m_oldPixmap=new QPixmap(PlasmaApplet::pixmap())
> };
>
>
> any ideas?

to answer the question you asked, though:

inside of paintInterface, paint everything onto a pixmap and then blit that 
pixmap using the QPainter passed in as the final step, e.g. something like 
this semi-pseudocode:

if (m_oldPixmap->size() != size()) {
    delete m_oldPixmap;
    m_oldPixmap = new QPixmap(size());
    m_oldPixmap->fill(QColor(Qt::transparent));
}

QPainter painter(m_oldPixmap);
... do the painting ...
painter.end();
p->drawPixmap(option->rect, m_oldPixmap, option->rect);

-- 
Aaron J. Seigo
humru othro a kohnu se
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43

KDE core developer sponsored by Qt Software

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel

Reply via email to