简而言之:这段代码位于main函数中,这很有效.此代码在两个图形元素上执行交换. 
QTimer timer;
timer.setTimerType(Qt::PreciseTimer);
timer.setInterval(1000.0/30.0);
timer.setSingleShot(false);
// ====================== MOVE 4 in POS of 1 ==========================
QPointF centre(QLineF(button1->pos(), button4->pos()).pointAt(0.5));
QPointF positionBut4 = button4->pos();
MyPointF centreSwap4(0, &positionBut4, ¢re);
button4->myPointF = ¢reSwap4;
QObject::connect(&timer, SIGNAL(timeout()), ¢reSwap4, SLOT(updateDownRight()));
QObject::connect(¢reSwap4, SIGNAL(positionChanged()), button4, SLOT(slotMoveCircle()));
// ====================== MOVE 4 in POS of 1 ==========================
// ====================== MOVE 1 in POS of 4 ==========================
QPointF positionBut1 = button1->pos();
MyPointF centreSwap1(0, &positionBut1, ¢re);
button1->myPointF = ¢reSwap1;
QObject::connect(&timer, SIGNAL(timeout()), ¢reSwap1, SLOT(updateUpLeft()));
QObject::connect(¢reSwap1, SIGNAL(positionChanged()), button1, SLOT(slotMoveCircle()));
// ====================== MOVE 1 in POS …Run Code Online (Sandbox Code Playgroud)