Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 4

Qt-interest Archive, January 2008
How to use QPainter inside QGraphicsPixmapItem?


Message 1 in thread

Hi!

I am trying to create a QGraphicsPixmapItem and then use the QPainter to
draw freehand lines inside the item. Does any body know if it is possible?
Could you give me a exemple? If it is not, does any body have an alternative
way to do this?

I am using QT 4.3 and Windows XP.

Thanks!

-- 
 [ signature omitted ] 

Message 2 in thread

William Marques Dias wrote:
> Hi!
>
> I am trying to create a QGraphicsPixmapItem and then use the QPainter 
> to draw freehand lines inside the item. Does any body know if it is 
> possible? Could you give me a exemple? If it is not, does any body 
> have an alternative way to do this?
>
> I am using QT 4.3 and Windows XP.
>
> Thanks!
>
> -- 
> William Marques Dias 
Hi William!

You can try to inherit QGraphicsPixmapItem and overload paint method 
like this:

void YourClass::paint(QPainter *p, const QStyleOptionGraphicsItem *o, 
QWidget *w) {
    // draw here what you wish using p
    QGraphicsPixmapItem::paint(p, o, w);
}

Anton I Alferov

--
 [ signature omitted ] 

Message 3 in thread

On torsdag den 31. Januar 2008, William Marques Dias wrote:
> Hi!
>
> I am trying to create a QGraphicsPixmapItem and then use the QPainter to
> draw freehand lines inside the item. Does any body know if it is possible?
> Could you give me a exemple? If it is not, does any body have an
> alternative way to do this?
>
> I am using QT 4.3 and Windows XP.

QPixmap pixmap = item->pixmap;
QPainter painter(&pixmap);
// Paint here
painter.end();
item->setPixmap(pixmap);

Bo.

-- 
 [ signature omitted ] 

Message 4 in thread

    QPixmap pixmap;
    QPainter painter;
    QRectF * rect  = new QRectF(startPoint, endPoint);
    painter.begin(&pixmap);
    painter.drawRect(*rect);
    painter.end();

I tried this, but i get the warning: QPainter::begin: Paint device returned
engine == 0, type: 2
any idea?


2008/1/31, Bo Thorsen <bo@xxxxxxxxxxxxxxxxxxxxx>:
>
> On torsdag den 31. Januar 2008, William Marques Dias wrote:
> > Hi!
> >
> > I am trying to create a QGraphicsPixmapItem and then use the QPainter to
> > draw freehand lines inside the item. Does any body know if it is
> possible?
> > Could you give me a exemple? If it is not, does any body have an
> > alternative way to do this?
> >
> > I am using QT 4.3 and Windows XP.
>
> QPixmap pixmap = item->pixmap;
> QPainter painter(&pixmap);
> // Paint here
> painter.end();
> item->setPixmap(pixmap);
>
> Bo.
>
> --
>
> Thorsen Consulting ApS - Qt consulting services
> http://www.thorsen-consulting.dk
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>


-- 
 [ signature omitted ]