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

Qt-interest Archive, April 2008
qgraphicsitem can not show QImage?


Message 1 in thread

I am trying to make an animation by subclassing QObject and QgraphicsItem.
The following is my paint function:
void MyItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *,
QWidget *)
{
   QImage image(":/images/myimage.jpg");
   painter->drawImage(0, 0, image);
}


However, in my graphics view I cannot see the image. But the item() function
detects it. What was wrong with my code, why I can
not show the image?


Thank you in advance.

Dave.

Message 2 in thread

On Friday 11 April 2008 9:08:50 pm Dave Sun wrote:
> I am trying to make an animation by subclassing QObject and QgraphicsItem.
> The following is my paint function:
> void MyItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *,
> QWidget *)
> {
>    QImage image(":/images/myimage.jpg");
>    painter->drawImage(0, 0, image);
> }
>
>
> However, in my graphics view I cannot see the image. But the item()
> function detects it. What was wrong with my code, why I can
> not show the image?
>
>
> Thank you in advance.
>
> Dave.

I'm not looking at the docs, but is your window already up? If so I'm pretty 
sure you need to tell it to show. If the window is not up, disregard. show is 
a member of QWidget IIRC.

-- 
 [ signature omitted ] 

Message 3 in thread

I figure out that I forgot to change the resource file. So the QImage
image(":/images/myimage.jpg") did not read out the file.

Thank you.
Have a nice weekend.

On Sat, Apr 12, 2008 at 12:37 AM, Eric Laffoon <sequitur@xxxxxxx> wrote:

> On Friday 11 April 2008 9:08:50 pm Dave Sun wrote:
> > I am trying to make an animation by subclassing QObject and
> QgraphicsItem.
> > The following is my paint function:
> > void MyItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *,
> > QWidget *)
> > {
> >    QImage image(":/images/myimage.jpg");
> >    painter->drawImage(0, 0, image);
> > }
> >
> >
> > However, in my graphics view I cannot see the image. But the item()
> > function detects it. What was wrong with my code, why I can
> > not show the image?
> >
> >
> > Thank you in advance.
> >
> > Dave.
>
> I'm not looking at the docs, but is your window already up? If so I'm
> pretty
> sure you need to tell it to show. If the window is not up, disregard. show
> is
> a member of QWidget IIRC.
>
> --
> Eric Laffoon
> Project Lead Quanta plus/Kommander
> http://kdewebdev.org
>
> --
> 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/
>
>