Is it possible to freeze QWidget during QPropertyAnimation works
-
Hi.
There is the next issue: I have two widgets witch I have added to SlidingStackWidget that was inherited from QStackWidget. The main idea make smooth animation while switching between two widgets from QStackWidget.
The main problem: one of child widget is having a very heavy paintEvent, so when animation is working it looks ugly when this QWidget with huge paintEvent logic moving. I am not sure if that an issue in that case. But if it is, if there way how I could change paintEvent just before animation to denied draw again and again logic with many conditions, but just freeze widget as it is in moment of animation starting and just move freeze rectangle?
I just wondering is there something likeQObject::installEventFilter
where I need to set up this logic and change it from custom to freeze?Thanks in advance
-
Hi
There is
setUpdatesEnabled(false); -
@mrjj said in Is it possible to freeze QWidget during QPropertyAnimation works:
setUpdatesEnabled(false);
Thanks.
Unfortunately, it does not solve my problem. The thing is, in this case I disable paintEvent() at all, so there is no animation between sliding. -
I mean I need something like save current view of widget without further updating till animation finished and draw this snapshot again and again during animation, which probably less heavy action then use custom paintEvent...
-
@mrjj said in Is it possible to freeze QWidget during QPropertyAnimation works:
setUpdatesEnabled(false);
Thanks.
Unfortunately, it does not solve my problem. The thing is, in this case I disable paintEvent() at all, so there is no animation between sliding.@Romaniy173
But did you disable painting only for the heavy widget ??
widget->setUpdatesEnabled(false);not for all of stackedwidget
-
I have disabled for all widgets(only two there). I did like that because I want to change widgets by sliding side by side like that:
pNext->move(pNext->x() - OffsetX, pNext->y() - OffsetY); pNext->show(); pNext->raise(); auto *pCurrent = currentWidget(); auto *pAnimationCurrent = new QPropertyAnimation(pCurrent, "pos"); pAnimationCurrent->setDuration(mp_Duration); pAnimationCurrent->setStartValue(QPoint(pCurrent->x(), pCurrent->y())); pAnimationCurrent->setEndValue(QPoint(pCurrent->x() + OffsetX, pCurrent->y() + OffsetY)); auto *pAnimationNext = new QPropertyAnimation(pNext, "pos"); pAnimationNext->setDuration(mp_Duration); pAnimationNext->setStartValue(QPoint(pNext->x(), pNext->y())); pAnimationNext->setEndValue(QPoint(pNext->x() + OffsetX, pNext->y() + OffsetY)); auto *pAnimationGroup = new QParallelAnimationGroup(this); pAnimationGroup->addAnimation(pAnimationCurrent); pAnimationGroup->addAnimation(pAnimationNext);
-
hi
Ahh you are not animating the stacked widget pages but the widgets them self ? -
Yes, exactly
-
@mrjj I am sorry, what do you mean when said pages? Could you provide a web page where I could read about it?
-
@mrjj I am sorry, what do you mean when said pages? Could you provide a web page where I could read about it?
Hi,
Ok i though you animated some widgets inside the QStackedWidget.
Then disable painting will also disable seeing the sliding.The QStackWidget has multiple widgets. I call these pages but its actually more
correct to say widgets as it do not have to contain other widgets.Anyway, you could use event filer to steal the paint event and then draw rect yourself.
Alternatively use the Render function fo reach widget and draw images of the widget.