繁体   English   中英

QTProperty动画,更改QpushButton图标

[英]QTProperty animation, changing QpushButton Icon

我正在尝试用动画更改qpushbutton图标。 目前,我有一个包含按钮的面板。 在船上,我有球。 我想将球从当前位置移动到另一个单元,但是我想展示道路。 因此,我创建了QSequentialAnimationGroup,并添加了所有动画。 但在实施之后,不再显示按钮。 错误在哪里。 谢谢。

void MainWindow::ballWasMoved(std::vector<Node> road, ball type) {
QSequentialAnimationGroup* group = new QSequentialAnimationGroup();
for(unsigned int i = 1; i < road.size(); i++) {
    Node nextCell = road[i];
    Cell* current = cells[nextCell.y][nextCell.x];
    Cell* previous = cells[road[i-1].y][road[i-1].x];
    QPropertyAnimation *animation1 = new QPropertyAnimation(current, "icon");
    animation1->setDuration(1);
    animation1->setEndValue(mergedIcon(type, MatrixPoint(0,0)));

    QPropertyAnimation *animation2 = new QPropertyAnimation(previous, "icon");
    animation2->setDuration(1);
    animation2->setEndValue(QIcon("://Assets/cell_light.png"));

    QPropertyAnimation *animation3 = new QPropertyAnimation(current, "iconSize");
    animation3->setDuration(20);
    animation3->setStartValue(QSize(0, 0));
    animation3->setEndValue(QSize(70, 70));



    group->addAnimation(animation1);
    group->addAnimation(animation2);
    group->addAnimation(animation3);
}
   group->start();
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM