基于不透明度的Qt工具栏动画
基于不透明度的Qt工具栏动画,qt,qtoolbar,qpropertyanimation,Qt,Qtoolbar,Qpropertyanimation,Toolbar(SelectionToolBar)是允许的lefttoolbarea。现在被藏起来了。当我将鼠标移到应用程序的左边框时,它将带有定义为不透明度的动画。这很好用。但问题是,当我移动鼠标时,即将鼠标悬停在toolbuttons上,所有的toolbuttons都将隐藏,尽管我可以单击按钮,但它仍然有效。只有按钮显示(视图/外观)被隐藏。我怀疑“褪色效应”已经超出了范围。有解决办法吗 bool evenfilter(...) { ... QGraphicsOpacityEffec
Toolbar(SelectionToolBar)
是允许的lefttoolbarea
。现在被藏起来了。当我将鼠标移到应用程序的左边框时,它将带有定义为不透明度的动画。这很好用。但问题是,当我移动鼠标时,即将鼠标悬停在toolbuttons
上,所有的toolbuttons都将隐藏,尽管我可以单击按钮,但它仍然有效。只有按钮显示(视图/外观)被隐藏。我怀疑“褪色效应”已经超出了范围。有解决办法吗
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();
}
这应该是一个BUG
这是@KYL3R提到的一个BUG
要复制的演示:
#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);
到
为我提供一个类似QToolbar的bug。@eyllanesc我记得你回答过关于不透明度0.99的类似问题,但我找不到它。。。
mFadeAnimation.setEndValue(1);
mFadeAnimation.setEndValue(0.99);