QGraphicsPixmapItem with a special picture stops the application
-
Hi guys,
I add a QGraphicsPixmapItem to QGraphicsScene by doing this:QPixmap pic = QPixmap::fromImage(QImage(path));
QGraphicsPixmapItem *it = new
QGraphicsPixmapItem(pic);scene.addItem(it);
it->setFlags(ItemIsMovable);
the scene shows the picture very quickly, but when i click and drag the item, the application gives no resonpse until a few seconds later.
i debugged the application and found that the scene recrives the mousePressEvent 5 seconds later after my click action.
this is pretty strange because only the specail picture cause this bug.
the picture is a 2000*1500 png with only some grid lines.
i tried other pictues bigger or smaller, no bugs found.
i even tried scribble the special picture to get a new picture, and this bug disappeared.
-
So you're trying to move around an image whos memory size it at least 9MB and you're wondering why the thing is slow?
2000 times 1500 times (color depth...24bits?)
This isn't a bug. Once you understand what you're doing here, it becomes evident that you've got unrealistic expectations about performance. If the object is being moved while you are dragging it then the mouse events for all those intermediate locations are triggering redraw between the original position and the final destination. You should NEVER try to drag an object that huge at its full definition. The drag operation should only draw a rectangle so that you know where you are dragging to, and only display the image at its final destination after removing from the starting point.
-
Hi
Are you saying that if you take another 2000*1500 png file it works without any issues but as soon
as you use "that" image, it will crash ?
Does it contains transparent areas or what makes it special ?