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

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();
主站蜘蛛池模板: 白沙| 清河县| 牡丹江市| 桦甸市| 石阡县| 桃园市| 都安| 奇台县| 广东省| 牟定县| 逊克县| 广水市| 房山区| 宣化县| 通化市| 兴和县| 科技| 滨州市| 呼玛县| 石景山区| 和静县| 祥云县| 灵宝市| 泗阳县| 银川市| 临颍县| 清河县| 柘城县| 都安| 肇庆市| 康乐县| 辽源市| 乌鲁木齐市| 万州区| 敦化市| 施甸县| 西丰县| 扶绥县| 威信县| 汉中市| 永吉县|