QTProperty动画,改变QpushButton Icon

时间:2018-03-17 16:19:47

标签: c++ qt

我正在尝试用动画更改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();
}

0 个答案:

没有答案