当前位置: 首页>>代码示例>>C++>>正文


C++ QGraphicsItemAnimation类代码示例

本文整理汇总了C++中QGraphicsItemAnimation的典型用法代码示例。如果您正苦于以下问题:C++ QGraphicsItemAnimation类的具体用法?C++ QGraphicsItemAnimation怎么用?C++ QGraphicsItemAnimation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QGraphicsItemAnimation类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argv, char *args[])
{
    QApplication app(argv, args);

//! [0]
    QGraphicsItem *ball = new QGraphicsEllipseItem(0, 0, 20, 20);
    
    QTimeLine *timer = new QTimeLine(5000);
    timer->setFrameRange(0, 100);
    
    QGraphicsItemAnimation *animation = new QGraphicsItemAnimation;
    animation->setItem(ball);
    animation->setTimeLine(timer);

    for (int i = 0; i < 200; ++i) 
	animation->setPosAt(i / 200.0, QPointF(i, i));
    
    QGraphicsScene *scene = new QGraphicsScene();
    scene->setSceneRect(0, 0, 250, 250);
    scene->addItem(ball);

    QGraphicsView *view = new QGraphicsView(scene);
    view->show();

    timer->start();
//! [0]

    return app.exec();
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:29,代码来源:main.cpp

示例2: QMainWindow

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
// -----------------------------------------------------------------------
    ui->setupUi(this);
    QGraphicsScene *scene = new QGraphicsScene(this);
    ui->graphicsView->setScene(scene);
// -----------------------------------------------------------------------
    // kolor pedzla
    QBrush brush = QBrush(Qt::red);
    brush.setStyle(Qt::DiagCrossPattern);
    // tworzymy obiekts
    QGraphicsRectItem *rect = new QGraphicsRectItem(10, 10, 90, 90);
    rect->setBrush(brush);
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
    // definiujemy czas trwania animacji
    QTimeLine *timeLine = new QTimeLine(1000);
    timeLine->setFrameRange(0, 100);

    // definiujemy animacje
    QGraphicsItemAnimation *animation = new QGraphicsItemAnimation();
    animation->setItem(rect);
    animation->setTimeLine(timeLine);

    // animacja
    int odcinek = 100;
    for (int i = 0; i < 100; ++i)
        animation->setPosAt(i / 100.0, QPointF(i, i));

    // uruchamiamy scenę i animację
    scene->addItem(rect);
    timeLine->start();
}
开发者ID:EjdzEs,项目名称:IPP.przesuwanka,代码行数:35,代码来源:mainwindow.cpp

示例3: linearRotation

void tst_QGraphicsItemAnimation::linearRotation()
{
    QGraphicsItemAnimation animation;
    animation.setRotationAt(1, 1);

    for (int i = 0; i <= 10; ++i)
        QCOMPARE(animation.rotationAt(i / 10.0), qreal(i / 10.0));
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:8,代码来源:tst_qgraphicsitemanimation.cpp

示例4: newAnim

QTimeLine* newAnim(Line* ball, int in, int to, QEasingCurve curve)
{
    QTimeLine *NewTimer = new QTimeLine(speed);
    NewTimer->setEasingCurve(curve);

    QGraphicsItemAnimation* anim = new QGraphicsItemAnimation();
    anim->setItem(ball);
    anim->setTimeLine(NewTimer);
    anim->setRotationAt(0, in);
    anim->setRotationAt(1, to);

    return NewTimer;
}
开发者ID:Xambey,项目名称:learning,代码行数:13,代码来源:main.cpp

示例5: sipConvertFromType

static PyObject *meth_QGraphicsItemAnimation_item(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;

    {
        QGraphicsItemAnimation *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QGraphicsItemAnimation, &sipCpp))
        {
            QGraphicsItem *sipRes;

            Py_BEGIN_ALLOW_THREADS
            sipRes = sipCpp->item();
            Py_END_ALLOW_THREADS

            return sipConvertFromType(sipRes,sipType_QGraphicsItem,NULL);
        }
    }
开发者ID:ClydeMojura,项目名称:android-python27,代码行数:18,代码来源:sipQtGuiQGraphicsItemAnimation.cpp

示例6: slotAddAnimationItem

void MainWindow::slotAddAnimationItem() //在场景中加入一个动画星星
{
    StartItem *item = new StartItem;
    QGraphicsItemAnimation *anim = new QGraphicsItemAnimation;
    anim->setItem(item);
    QTimeLine *timeLine = new QTimeLine(4000);
    timeLine->setCurveShape(QTimeLine::SineCurve);
    timeLine->setLoopCount(0);

    anim->setTimeLine(timeLine);

    int y =(qrand()%400)-200;
    for(int i=0; i<400; i++)
    {
        anim->setPosAt(i/400.0,QPointF(i-200,y));
    }
    timeLine->start();
    scene->addItem(item);
}
开发者ID:Pengfei-Gao,项目名称:develop-reference-data,代码行数:19,代码来源:mainwindow.cpp

示例7: QGraphicsEllipseItem

MyScene::MyScene(qreal x,qreal y,qreal width,qreal height,QObject *parent):QGraphicsScene(x,y,width,height,parent) {
	// 預計加一個圓形,然後,執徑逐漸變大
	QGraphicsEllipseItem *ball = new QGraphicsEllipseItem(-15,-15,30,30);
	ball->setPen(QPen(QColor(125,125,125,125),3));
	addItem(ball);

	ball->setPos(this->width()/2,this->height()/2);	// setPos(x,y):設定此小座標的原點在此(x,y)

	timeLine = new QTimeLine;

	QGraphicsItemAnimation *headAnimation = new QGraphicsItemAnimation;
	headAnimation->setItem(ball);
	headAnimation->setTimeLine(timeLine);
	headAnimation->setScaleAt(1,10,10);

	timeLine->setUpdateInterval(1000 / 25);
	timeLine->setCurveShape(QTimeLine::SineCurve);
	timeLine->setLoopCount(0);
	timeLine->setDuration(2000);
	timeLine->start();
}
开发者ID:nightfly19,项目名称:renyang-learn,代码行数:21,代码来源:myscene.cpp

示例8: linearMove

void tst_QGraphicsItemAnimation::linearMove()
{
    QGraphicsItemAnimation animation;

    for (int i = 0; i <= 10; ++i) {
        QCOMPARE(animation.posAt(i / 10.0).x(), qreal(0));
        QCOMPARE(animation.posAt(i / 10.0).y(), qreal(0));
    }

    animation.setPosAt(1, QPointF(10, -10));

    for (int i = 0; i <= 10; ++i) {
        QCOMPARE(animation.posAt(i / 10.0).x(), qreal(i));
        QCOMPARE(animation.posAt(i / 10.0).y(), qreal(-i));
    }

    animation.setPosAt(2, QPointF(10, -10));

    QCOMPARE(animation.posAt(11).x(), qreal(10));
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:20,代码来源:tst_qgraphicsitemanimation.cpp

示例9: RobotTorso

Robot::Robot()
{
    QGraphicsItem *torsoItem = new RobotTorso(this);    
    QGraphicsItem *headItem = new RobotHead(torsoItem);
    QGraphicsItem *upperLeftArmItem = new RobotLimb(torsoItem);
    QGraphicsItem *lowerLeftArmItem = new RobotLimb(upperLeftArmItem);
    QGraphicsItem *upperRightArmItem = new RobotLimb(torsoItem);
    QGraphicsItem *lowerRightArmItem = new RobotLimb(upperRightArmItem);
    QGraphicsItem *upperRightLegItem = new RobotLimb(torsoItem);
    QGraphicsItem *lowerRightLegItem = new RobotLimb(upperRightLegItem);
    QGraphicsItem *upperLeftLegItem = new RobotLimb(torsoItem);
    QGraphicsItem *lowerLeftLegItem = new RobotLimb(upperLeftLegItem);
    
    headItem->setPos(0, -18);
    upperLeftArmItem->setPos(-15, -10);
    lowerLeftArmItem->setPos(30, 0);
    upperRightArmItem->setPos(15, -10);
    lowerRightArmItem->setPos(30, 0);
    upperRightLegItem->setPos(10, 32);
    lowerRightLegItem->setPos(30, 0);
    upperLeftLegItem->setPos(-10, 32);
    lowerLeftLegItem->setPos(30, 0);

    timeLine = new QTimeLine;

    QGraphicsItemAnimation *headAnimation = new QGraphicsItemAnimation;
    headAnimation->setItem(headItem);
    headAnimation->setTimeLine(timeLine);
    headAnimation->setRotationAt(0, 20);
    headAnimation->setRotationAt(1, -20);
    headAnimation->setScaleAt(1, 1.1, 1.1);

    QGraphicsItemAnimation *upperLeftArmAnimation = new QGraphicsItemAnimation;
    upperLeftArmAnimation->setItem(upperLeftArmItem);
    upperLeftArmAnimation->setTimeLine(timeLine);
    upperLeftArmAnimation->setRotationAt(0, 190);
    upperLeftArmAnimation->setRotationAt(1, 180);

    QGraphicsItemAnimation *lowerLeftArmAnimation = new QGraphicsItemAnimation;
    lowerLeftArmAnimation->setItem(lowerLeftArmItem);
    lowerLeftArmAnimation->setTimeLine(timeLine);
    lowerLeftArmAnimation->setRotationAt(0, 50);
    lowerLeftArmAnimation->setRotationAt(1, 10);
    
    QGraphicsItemAnimation *upperRightArmAnimation = new QGraphicsItemAnimation;
    upperRightArmAnimation->setItem(upperRightArmItem);
    upperRightArmAnimation->setTimeLine(timeLine);
    upperRightArmAnimation->setRotationAt(0, 300);
    upperRightArmAnimation->setRotationAt(1, 310);

    QGraphicsItemAnimation *lowerRightArmAnimation = new QGraphicsItemAnimation;
    lowerRightArmAnimation->setItem(lowerRightArmItem);
    lowerRightArmAnimation->setTimeLine(timeLine);
    lowerRightArmAnimation->setRotationAt(0, 0);
    lowerRightArmAnimation->setRotationAt(1, -70);

    QGraphicsItemAnimation *upperLeftLegAnimation = new QGraphicsItemAnimation;
    upperLeftLegAnimation->setItem(upperLeftLegItem);
    upperLeftLegAnimation->setTimeLine(timeLine);
    upperLeftLegAnimation->setRotationAt(0, 150);
    upperLeftLegAnimation->setRotationAt(1, 80);

    QGraphicsItemAnimation *lowerLeftLegAnimation = new QGraphicsItemAnimation;
    lowerLeftLegAnimation->setItem(lowerLeftLegItem);
    lowerLeftLegAnimation->setTimeLine(timeLine);
    lowerLeftLegAnimation->setRotationAt(0, 70);
    lowerLeftLegAnimation->setRotationAt(1, 10);

    QGraphicsItemAnimation *upperRightLegAnimation = new QGraphicsItemAnimation;
    upperRightLegAnimation->setItem(upperRightLegItem);
    upperRightLegAnimation->setTimeLine(timeLine);
    upperRightLegAnimation->setRotationAt(0, 40);
    upperRightLegAnimation->setRotationAt(1, 120);
    
    QGraphicsItemAnimation *lowerRightLegAnimation = new QGraphicsItemAnimation;
    lowerRightLegAnimation->setItem(lowerRightLegItem);
    lowerRightLegAnimation->setTimeLine(timeLine);
    lowerRightLegAnimation->setRotationAt(0, 10);
    lowerRightLegAnimation->setRotationAt(1, 50);
    
    QGraphicsItemAnimation *torsoAnimation = new QGraphicsItemAnimation;
    torsoAnimation->setItem(torsoItem);
    torsoAnimation->setTimeLine(timeLine);
    torsoAnimation->setRotationAt(0, 5);
    torsoAnimation->setRotationAt(1, -20);

    timeLine->setUpdateInterval(1000 / 25);
    timeLine->setCurveShape(QTimeLine::SineCurve);
    timeLine->setLoopCount(0);
    timeLine->setDuration(2000);
    timeLine->start();
}
开发者ID:eagafonov,项目名称:qtmoko,代码行数:92,代码来源:robot.cpp

示例10: construction

void tst_QGraphicsItemAnimation::construction()
{
    QGraphicsItemAnimation animation;
    QVERIFY(!animation.item());
    QVERIFY(!animation.timeLine());
    QCOMPARE(animation.posAt(0), QPointF());
    QCOMPARE(animation.posAt(0.5), QPointF());
    QCOMPARE(animation.posAt(1), QPointF());
    QCOMPARE(animation.matrixAt(0), QMatrix());
    QCOMPARE(animation.matrixAt(0.5), QMatrix());
    QCOMPARE(animation.matrixAt(1), QMatrix());
    QCOMPARE(animation.rotationAt(0), qreal(0.0));
    QCOMPARE(animation.rotationAt(0.5), qreal(0.0));
    QCOMPARE(animation.rotationAt(1), qreal(0.0));
    QCOMPARE(animation.xTranslationAt(0), qreal(0.0));
    QCOMPARE(animation.xTranslationAt(0.5), qreal(0.0));
    QCOMPARE(animation.xTranslationAt(1), qreal(0.0));
    QCOMPARE(animation.yTranslationAt(0), qreal(0.0));
    QCOMPARE(animation.yTranslationAt(0.5), qreal(0.0));
    QCOMPARE(animation.yTranslationAt(1), qreal(0.0));
    QCOMPARE(animation.verticalScaleAt(0), qreal(1.0));
    QCOMPARE(animation.horizontalScaleAt(0), qreal(1.0));
    QCOMPARE(animation.verticalShearAt(0), qreal(0.0));
    QCOMPARE(animation.horizontalShearAt(0), qreal(0.0));
    animation.clear(); // don't crash
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:26,代码来源:tst_qgraphicsitemanimation.cpp

示例11: setTimeLine

void tst_QGraphicsItemAnimation::setTimeLine()
{
    QGraphicsItemAnimation animation;
    QCOMPARE(animation.timeLine(), (QTimeLine *)0);

    QPointer<QTimeLine> line1 = new QTimeLine;
    animation.setTimeLine(line1);
    QCOMPARE(animation.timeLine(), (QTimeLine *)line1);
    animation.setTimeLine(line1);
    QVERIFY(line1);
    QCOMPARE(animation.timeLine(), (QTimeLine *)line1);

    animation.setTimeLine(0);
    QCOMPARE(animation.timeLine(), (QTimeLine *)0);
    QVERIFY(!line1);

    QTimeLine *line2 = new QTimeLine;
    animation.setTimeLine(line2);
    QCOMPARE(animation.timeLine(), (QTimeLine *)line2);

    delete line2;
    QCOMPARE(animation.timeLine(), (QTimeLine *)0);
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:23,代码来源:tst_qgraphicsitemanimation.cpp

示例12: overwriteValueForStep

void tst_QGraphicsItemAnimation::overwriteValueForStep()
{
    QGraphicsItemAnimation animation;

    for (int i=0; i<3; i++){
        animation.setPosAt(0.3, QPointF(3, -3.1));
        animation.setRotationAt(0.3, 2.3);
        animation.setTranslationAt(0.3, 15, 15);
        animation.setScaleAt(0.3, 2.5, 1.8);
        animation.setShearAt(0.3, 5, 5);

        QCOMPARE(animation.posList().size(), 1);
        QCOMPARE(animation.rotationList().size(), 1);
        QCOMPARE(animation.translationList().size(), 1);
        QCOMPARE(animation.scaleList().size(), 1);
        QCOMPARE(animation.shearList().size(), 1);
    }
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:18,代码来源:tst_qgraphicsitemanimation.cpp

示例13: checkReturnedLists

void tst_QGraphicsItemAnimation::checkReturnedLists()
{
    QGraphicsItemAnimation animation;

    animation.setPosAt(1.0, QPointF(10, -10));
    animation.setPosAt(0.5, QPointF(5, -5));

    animation.setRotationAt(0.3, 2.3);
    animation.setTranslationAt(0.3, 15, 15);
    animation.setScaleAt(0.3, 2.5, 1.8);
    animation.setShearAt(0.3, 5, 5);

    QCOMPARE(animation.posList().at(0), (QPair<qreal, QPointF>(0.5, QPointF(5, -5))));
    QCOMPARE(animation.posList().at(1), (QPair<qreal, QPointF>(1.0, QPointF(10, -10))));
    QCOMPARE(animation.rotationList().at(0), (QPair<qreal, qreal>(0.3, 2.3)));
    QCOMPARE(animation.translationList().at(0), (QPair<qreal, QPointF>(0.3, QPointF(15, 15))));
    QCOMPARE(animation.scaleList().at(0), (QPair<qreal, QPointF>(0.3, QPointF(2.5, 1.8))));
    QCOMPARE(animation.shearList().at(0), (QPair<qreal, QPointF>(0.3, QPointF(5, 5))));

    QCOMPARE(animation.posList().size(), 2);
    QCOMPARE(animation.rotationList().size(), 1);
    QCOMPARE(animation.translationList().size(), 1);
    QCOMPARE(animation.scaleList().size(), 1);
    QCOMPARE(animation.shearList().size(), 1);
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:25,代码来源:tst_qgraphicsitemanimation.cpp

示例14: EnemyShipTail

EnemyShip::EnemyShip()
{
    QGraphicsItem *spaceshipTail = new EnemyShipTail(this);
    QGraphicsItem *oneWing = new EnemyShipWing1(this);
    QGraphicsItem *secondWing = new EnemyShipWing2(this);
    QGraphicsItem *spaceshipBody = new EnemyShipBody(this);
    QGraphicsItem *spaceshipWindow = new EnemyShipWindow(this);

    spaceshipTail->setPos(602, 293);
    oneWing->setPos(565, 310);
    secondWing->setPos(623, 310);
    spaceshipBody->setPos(600, 300);
    spaceshipWindow->setPos(607, 332);

    timeline = new QTimeLine;

    QGraphicsItemAnimation *tailAnim = new QGraphicsItemAnimation;
    tailAnim->setItem(spaceshipTail);
    tailAnim->setTimeLine(timeline);
    tailAnim->setTranslationAt(0, 20, 0);
    tailAnim->setTranslationAt(1, -20, 0);

    QGraphicsItemAnimation *oneWingAnim = new QGraphicsItemAnimation;
    oneWingAnim->setItem(oneWing);
    oneWingAnim->setTimeLine(timeline);
    oneWingAnim->setTranslationAt(0, 20, 0);
    oneWingAnim->setTranslationAt(1, -20, 0);

    QGraphicsItemAnimation *secondWingAnim = new QGraphicsItemAnimation;
    secondWingAnim->setItem(secondWing);
    secondWingAnim->setTimeLine(timeline);
    secondWingAnim->setTranslationAt(0, 20, 0);
    secondWingAnim->setTranslationAt(1, -20, 0);

    QGraphicsItemAnimation *bodyAnim = new QGraphicsItemAnimation;
    bodyAnim->setItem(spaceshipBody);
    bodyAnim->setTimeLine(timeline);
    bodyAnim->setTranslationAt(0, 20, 0);
    bodyAnim->setTranslationAt(1, -20, 0);

    QGraphicsItemAnimation *windowAnim = new QGraphicsItemAnimation;
    windowAnim->setItem(spaceshipWindow);
    windowAnim->setTimeLine(timeline);
    windowAnim->setTranslationAt(0, 20, 0);
    windowAnim->setTranslationAt(1, -20, 0);

    timeline->setUpdateInterval(1000/25);
    timeline->setCurveShape(QTimeLine::SineCurve);
    timeline->setLoopCount(0);
    timeline->setDuration(2000);
    timeline->start();

}
开发者ID:hdwilber,项目名称:earth20000,代码行数:53,代码来源:enemyShip.cpp


注:本文中的QGraphicsItemAnimation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。