Toolbar(SelectionToolBar)
is allowed LeftToolbarArea
. and is presently hidden. When i take the mouse to the left border of the application, it will come with animation defined on opacity. This is working fine. But the problem is when I move over the mouse i.e. hover on toolbuttons
, all toolbuttons will hide though I can click buttons, its working. Only the toobutton display(view/look) is getting hidden. I am suspecting "fade_effect" it is going out of scope. Any solution?
bool evenfilter(...)
{
...
QGraphicsOpacityEffect* fade_effect = new QGraphicsOpacityEffect();
ui->SelectionToolbar->setGraphicsEffect(fade_effect);
QPropertyAnimation *animation = new QPropertyAnimation(fade_effect, "opacity");
animation->setEasingCurve(QEasingCurve::InOutQuad);
animation->setDuration(3000);
animation->setStartValue(0.01);
animation->setEndValue(1.0);
animation->start(QPropertyAnimation::DeleteWhenStopped);
//animation->start();
ui->SelectionToolbar->show();
}
This shall be a BUG
It's a BUG as @KYL3R mentioned
Demo to reproduce:
#include <QToolBar>
#include <QToolButton>
#include <QGraphicsOpacityEffect>
#include <QPropertyAnimation>
class ToolBar : public QToolBar
{
Q_OBJECT
public:
ToolBar(QWidget *parent = Q_NULLPTR) :
QToolBar(parent)
{
setGraphicsEffect(&mFadeEffect);
mFadeAnimation.setTargetObject(&mFadeEffect);
mFadeAnimation.setPropertyName("opacity");
mFadeAnimation.setStartValue(0.0);
mFadeAnimation.setEndValue(1);
mFadeAnimation.setDuration(3000);
mFadeAnimation.start();
}
virtual ~ToolBar() {}
private:
QGraphicsOpacityEffect mFadeEffect;
QPropertyAnimation mFadeAnimation;
};
auto toolbar = new ToolBar();
toolbar->addAction("action 1");
toolbar->addAction("action 2");
toolbar->addAction("action 3");
addToolBar(Qt::LeftToolBarArea, toolbar);
Temp solution:
change
mFadeAnimation.setEndValue(1);
to
mFadeAnimation.setEndValue(0.99);