QGraphicsLineItem *line;

    scene->addItem(line = new QGraphicsLineItem(QLineF(QPointF(0, 0), QPointF(300, 300))));   //在创景窗口中画一条直线
    line->setPen(QPen(Qt::DashDotDotLine));

    QGraphicsItemAnimation *animation = new QGraphicsItemAnimation;
    animation->setItem(line);
    //scene->addItem(animation);

    //怎样动需要QTimeLiness函数
    QTimeLine *timeline = new QTimeLine();      //持续三秒钟
    timeline->setLoopCount(NULL);                      //设置循环次数

    animation->setTimeLine(timeline);
    //animation->rotationAt(45);                      //以怎样的角度进行旋转
    animation->setTranslationAt(1, 200, 200);

    timeline->start();

    _timer = new QTimer();
    _timer->setInterval(1000);       //设置间隔时间
    connect(_timer, SIGNAL(timeout()), this, SLOT(slotTimeOut()));
    _timer->start();

相关文章:

  • 2021-06-20
  • 2021-11-07
  • 2022-12-23
  • 2022-12-23
  • 2022-01-09
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-16
  • 2021-10-30
相关资源
相似解决方案