PDA

View Full Version : weird problem in QGraphicsView / QGraphicsScene



Mrdata
24th November 2009, 12:25
i've a weird problem, i want to display an image (size 1024x150) in the bottom of my application window. It's a QGraphicsScene inside a QGraphicsView, my main window is 1024x768 size, first i tried to add the image as this:



bottom_widget = new QLabel;
bottom_widget->setPixmap( QPixmap( "images/bottom.png" ) );
bottom_proxy = scene.addWidget( botbar_widget );
bottom_proxy->setPos( 0, 618 );
bottom_proxy->setZValue( 1 );
bottom_proxy->setAttribute( Qt::WA_DeleteOnClose, true );


and the result was this:
see _Image001.jpg

part of the image on the right is grey? don't have a clue why, it should be the same colour/pattern of the rest of the image.

if i move the image to the left, putting something like this:

bottom_proxy->setPos( -512, 618 );
the right part of the image displays ok

now, if i try to add the image using QGraphicsPixmapItem method:


bottom_Item = new QGraphicsPixmapItem( 0, &scene );
bottom_Item->setPixmap( QPixmap( "images/bottom.png" ) );
bottom_Item->setPos( 0, 618 );
bottom_Item->setZValue( 1 );


the image displays on the mainwindow as it should be, no grey area on the right but now
when i try to exit from that part of my application (and bottom_item is removed from the scene and deleted), the first time it works fine (it's removed/deleted ok), when i enter again that section of my application and it displays the same image, when i then try to exit from that part, the application crashes in this line:



qvector.h
inline void detach() { if (d->ref != 1) detach_helper(); }


but, if again if move the item to the left, ( position -512, 618 ), it doesn't crash.
so, first time works fine, second time it crashes in the above section.

sorry if this seems confusing, for long hours i tried to spot what causes this weird problem but at this time i don't have any clue.

i'm using qt 4.5.0

thanks in advance

wysota
24th November 2009, 18:20
Please prepare a minimal compilable example reproducing the problem.

Mrdata
24th November 2009, 18:31
thanks, i'll do that, but it'll take some time because this part is deeply nested inside my main application.
meanwhile and at first sight can you spot something? has someone had similar problem?

wysota
24th November 2009, 20:26
I just see a few lines of code that are syntactically correct, nothing more.