我想用动画改变小部件的背景颜色(如qlabel).事实上,我希望在QMainWindow上运行淡入淡出动画以获得子窗口小部件的背景颜色.所以,我写了一些如下代码:
QPropertyAnimation *animation = new QPropertyAnimation(ui->label1, "styleSheet");
animation->setStartValue("background-color: rgb(240, 240, 240)");
animation->setEndValue("background-color: rgb(126, 194, 66)");
animation->setDuration(3000);
animation->start();
Run Code Online (Sandbox Code Playgroud)
但没有变化!
我该怎么做?
谢谢 :-)
它解决了:-)
qt ×1