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

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();
主站蜘蛛池模板: 松桃| 江阴市| 斗六市| 四子王旗| 常宁市| 阳原县| 芦溪县| 维西| 东乌珠穆沁旗| 县级市| 保德县| 辰溪县| 句容市| 灵石县| 阿图什市| 建宁县| 余庆县| 民和| 杨浦区| 六盘水市| 高陵县| 泽库县| 成安县| 紫云| 福泉市| 海林市| 赤城县| 句容市| 朝阳市| 澄城县| 孝昌县| 连云港市| 阿瓦提县| 潍坊市| 句容市| 宜城市| 北宁市| 忻城县| 江山市| 宁强县| 安徽省|