Can I mix QGraphicsOpacityEffect with animation
-
Hi
I want to add animation toQGraphicsPixmapItem
when it was added into theQGraphicsScene
.
For example, when I add aQGraphicsPixmapItem
, it will be movedfrom pos1 to pos2 , or showed from opacity(0) to opacity(1)Regards
Mihan@Mihan Should be possible with https://doc.qt.io/qt-5/animation.html
-
@Mihan Should be possible with https://doc.qt.io/qt-5/animation.html
@jsulm
Oh maybe my description is not clear enough.{ // here has a item ready to be added QGraphicsPixmapItem *item = new QGraphicsPixmapItem(); //I add effect QGraphicsOpacity *effect = new QGraphicsOpacity(); item ->setGraphicsEffect(effect); // add animation QPropertyAnimation *animation = new QPropertyAnimation(effect, "opacity"); //but I don't know when the item is showed so that I don't know when the animation should be started. //If it has a function like QWidget::showEvent(). I could override it. }
Also I want to make a
CMyGraphicsPixmapItem
based onQGraphicsPixmapItem
withQPropertyAnimation
QGraphicsOpacity
-
Hi
You can try to use ItemChange
https://doc.qt.io/qt-5/qgraphicsitem.html#GraphicsItemChange-enum
it has info about visibility via QGraphicsItem::ItemVisibleChange -
Hi
You can try to use ItemChange
https://doc.qt.io/qt-5/qgraphicsitem.html#GraphicsItemChange-enum
it has info about visibility via QGraphicsItem::ItemVisibleChange