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

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();
主站蜘蛛池模板: 合水县| 大庆市| 永平县| 静安区| 平南县| 黑龙江省| 涿鹿县| 房产| 漾濞| 广元市| 梁山县| 成安县| 霞浦县| 正定县| 德清县| 兴海县| 芜湖市| 谢通门县| 长海县| 和林格尔县| 沐川县| 麦盖提县| 垣曲县| 兴国县| 仙桃市| 道孚县| 彩票| 汾西县| 安图县| 通河县| 大同市| 方正县| 孟村| 嘉定区| 定陶县| 江永县| 绥芬河市| 宜兴市| 石楼县| 大厂| 阳山县|