官术网_书友最值得收藏!

How to do it…

In the following example, we will create a new widget project and animate the push button by changing its properties:

  1. Let's create a new Qt Widgets Application project. After that, open up mainwindow.ui with Qt Designer and place a button on the main window, as shown here:

  1. Open up mainwindow.cpp and add the following line of code at the beginning of the source code:

 #include <QPropertyAnimation>
  1. After that, open up mainwindow.cpp and add the following code to the constructor:
QPropertyAnimation *animation = new QPropertyAnimation(ui->pushButton, "geometry");
animation->setDuration(10000);
animation->setStartValue(ui->pushButton->geometry());
animation->setEndValue(QRect(200, 200, 100, 50));
animation->start();
主站蜘蛛池模板: 南昌县| 万载县| 土默特右旗| 云梦县| 阜宁县| 吴江市| 永吉县| 西安市| 阳朔县| 崇左市| 嵊泗县| 固安县| 绍兴县| 隆安县| 上饶县| 织金县| 新津县| 洛川县| 报价| 南投县| 志丹县| 府谷县| 左贡县| 荆门市| 中西区| 玉树县| 称多县| 长垣县| 胶州市| 关岭| 贵阳市| 泰和县| 伊宁县| 淮安市| 乐业县| 四川省| 郯城县| 正安县| 武安市| 旅游| 湘西|