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


C++ QTimeLine类代码示例

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


在下文中一共展示了QTimeLine类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: QTimeLine

void smallPictureView::movItemPos(int i){

    allPixItem.at(i)->show();
    QTimeLine *timeLine = new QTimeLine(300);
    timeLine->setFrameRange(0, 300);
    midPixItemFlag->hide();
    scene.setSceneRect(0,widheight-81,widwidth,48);
    //scene.setSceneRect(-widwidth/2, -24,widwidth,48);
    allAnimation.at(i)->setTimeLine(timeLine);
    allAnimation.at(i)->clear();
    allAnimation.at(i)->setItem(allPixItem.at(i));
    if(i<selectedNum){//left
        //将该项目的位置设置为给定的步长值到指定的点。
        allAnimation.at(i)->setPosAt(1, QPointF((36+1)*(i-selectedNum-1)+width()/2.0,widheight-81));
    }else if(i>selectedNum){//right
        //将该项目的位置设置为给定的步长值到指定的点。
        allAnimation.at(i)->setPosAt(1, QPointF(3+(36+1)*(i-selectedNum)+width()/2.0,widheight-81));
    }else{//selected
        if(selectedNum!=oldSelectNum){

            midPixItemFlag->hide();
            oldSelectNum = selectedNum;
        }
        //将该项目的位置设置为给定的步长值到指定的点。
        allAnimation.at(i)->setPosAt(1, QPointF(3-18+(36+1)*(i-selectedNum)+width()/2.0,widheight-81));
        connect(timeLine,SIGNAL(finished()),this,SLOT(timelineFinished()));
    }
    timeLine->start();
}
开发者ID:wangzhen0625,项目名称:PictureBrowse-1.2zhenghe,代码行数:29,代码来源:smallpictureview.cpp

示例3: QGraphicsView

PhotoKitView::PhotoKitView(QWidget *parent) :
	QGraphicsView(parent),mPressed(false),mMachine(0),mCanTransform(true),mZoomOnMove(false)
{
	//setDragMode(QGraphicsView::NoDrag);
    //setAlignment(Qt::AlignBottom);
    //setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
    setTransformationAnchor(QGraphicsView::AnchorViewCenter);
    setResizeAnchor(QGraphicsView::AnchorUnderMouse);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); //TODO: always on when debug.
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    //setBackgroundBrush(QBrush(Qt::gray));
	mScene = new PhotoKitScene(this);

	setRenderingSystem();
	mScene->setSceneRect(qApp->desktop()->rect());
	setScene(mScene);

	mMachine = new TransformMachine;//QGraphicsItemAnimation;
	connect(mMachine, SIGNAL(transformChanged(QTransform)), SLOT(doTransform(QTransform)));

	QTimeLine *timer = new QTimeLine(kAniDuration);
	timer->setEasingCurve(QEasingCurve::OutQuad);
	timer->setFrameRange(0, 100);
	mMachine->setTimeLine(timer);
}
开发者ID:BIbiLion,项目名称:PhotoKit,代码行数:25,代码来源:PhotoKitView.cpp

示例4: 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

示例5: MarblePhysicsPrivate

 MarblePhysicsPrivate( MarbleAbstractPresenter *presenter )
     : m_presenter( presenter ),
       m_mode( Instant ),
       m_planetRadius( EARTH_RADIUS )
 {
     m_timeline.setDuration(2000);
     m_timeline.setCurveShape( QTimeLine::EaseInOutCurve );
 }
开发者ID:calincru,项目名称:marble,代码行数:8,代码来源:MarblePhysics.cpp

示例6: QGraphicsRectItem

Pong::Pong() {
    // players
    player1 = new QGraphicsRectItem(0, 0, PADDLE, PADDLE * 3);
    player1->setPos(PADDLE, (HEIGHT - PADDLE * 3) / 2);
    player1->setBrush(QBrush(Qt::gray));
    addItem(player1);
    player2 = new QGraphicsRectItem(0, 0, PADDLE, PADDLE * 3);
    player2->setPos(WIDTH - PADDLE * 2, (HEIGHT - PADDLE * 3) / 2);
    player2->setBrush(QBrush(Qt::gray));
    addItem(player2);

    // ball
    ball = new QGraphicsEllipseItem(0, 0, PADDLE, PADDLE);
    ball->setPos((WIDTH - PADDLE) / 2, (HEIGHT - PADDLE) / 2);
    ball->setBrush(QBrush(Qt::gray));
    addItem(ball);

    // score
    tscore1 = new QGraphicsSimpleTextItem();
    tscore1->setText("0");
    tscore1->setFont(QFont("Times", 36, QFont::Bold));
    tscore1->setPos(WIDTH / 2 - PADDLE - 24, PADDLE);
    tscore1->setBrush(QBrush(Qt::gray));
    addItem(tscore1);
    tscore2 = new QGraphicsSimpleTextItem();
    tscore2->setText("0");
    tscore2->setFont(QFont("Times", 36, QFont::Bold));
    tscore2->setPos(WIDTH / 2 + PADDLE, PADDLE);
    tscore2->setBrush(QBrush(Qt::gray));
    addItem(tscore2);

    // line
    int h = 0;
    int pointSize = PADDLE / 4;
    while (h < HEIGHT) {
        QGraphicsRectItem *linePoint = new QGraphicsRectItem(0, 0, pointSize, pointSize);
        linePoint->setBrush(QBrush(Qt::gray));
        linePoint->setPos((WIDTH - pointSize) / 2, h);
        addItem(linePoint);
        h += pointSize * 2;
    }

    score1 = 0;
    score2 = 0;
    dx = -1;
    dy = -1;
    speedUpCounter = 0;
    ballSpeed = 0.2;
    setSceneRect(0, 0, WIDTH, HEIGHT);
    setBackgroundBrush(QBrush(Qt::black));

    QTimeLine *timer = new QTimeLine();
    timer->setFrameRange(0, 100);
    timer->setLoopCount(10000);
    timer->start();

    connect(timer, SIGNAL(frameChanged(int)), this, SLOT(value_changed(int)));
}
开发者ID:andpei,项目名称:pong,代码行数:58,代码来源:pong.cpp

示例7: QTimeLine

void LinkDialogProcessorGraphicsItem::animationStart() {
    animateExpansion_ = 0.1f;

    QTimeLine* anim = new QTimeLine(50, this);
    anim->setUpdateInterval(20);
    connect(anim, SIGNAL(valueChanged(qreal)), SLOT(animate(qreal)));
    connect(anim, SIGNAL(finished()), SLOT(animationEnd()));
    anim->start();
}
开发者ID:sarbi127,项目名称:inviwo,代码行数:9,代码来源:linkdialogprocessorgraphicsitems.cpp

示例8: QTimeLine

void EditorView::startAnimation(char const *slot)
{
    QTimeLine *anim = new QTimeLine(zoomAnimationTimes * zoomAnimationInterval, this);
    anim->setUpdateInterval(zoomAnimationInterval);

    connect(anim, SIGNAL(valueChanged(qreal)), this, slot);
    connect(anim, SIGNAL(finished()), this, SLOT(animFinished()));
    anim->start();
}
开发者ID:DenisKogutich,项目名称:qreal,代码行数:9,代码来源:editorView.cpp

示例9: QTimeLine

void OnOffButton::animate(int xStart, int xEnd)
{
    QTimeLine *timeLine = new QTimeLine(300, this);
    timeLine->setFrameRange(xStart, xEnd);
    connect(timeLine, SIGNAL(frameChanged(int)), this, SLOT(updateAnimation(int)));
    timeLine->start();


}
开发者ID:dubstar-04,项目名称:squeezecontroll,代码行数:9,代码来源:onoffbutton.cpp

示例10: QTimeLine

void LinkDialogGraphicsScene::wheelAction(float offset) {
    currentScrollSteps_ = offset;

    QTimeLine* anim = new QTimeLine(750, this);
    anim->setUpdateInterval(20);
    connect(anim, SIGNAL(valueChanged(qreal)), SLOT(executeTimeLine(qreal)));
    connect(anim, SIGNAL(finished()), SLOT(terminateTimeLine()));
    anim->start();
}
开发者ID:cgloger,项目名称:inviwo,代码行数:9,代码来源:linkdialogscene.cpp

示例11: main

int main (int argc, char** argv)
{
    QApplication app(argc, argv);

    QGraphicsView view;
    QGraphicsScene *scene = new QGraphicsScene(&view);
    scene->setItemIndexMethod(QGraphicsScene::NoIndex);

    Line *left, *right, *right2;

    int of = pos_x;

    for(int i = 0; i < c; i++)
    {
        Line* ball = new Line(QPoint(of, -2));
        scene->addItem(ball);
        of += size;
        if(i==0)
            left = ball;
        else if(i == c - 1)
            right = ball;
        else if(i == c - 2)
            right2 = ball;
    }

    QTimeLine *LeftTimerTo      = newAnim(left,0,45,QEasingCurve::OutQuart);
    QTimeLine *LeftTimerReturn    = newAnim(left,45,0,QEasingCurve::InQuart);
    QTimeLine *RightTimerTo     = newAnim(right,0,-45,QEasingCurve::OutQuart);
    QTimeLine *RightTimerBack   = newAnim(right,-45,0,QEasingCurve::InQuart);
    QTimeLine *RightTimerTo2     = newAnim(right2,0,-45,QEasingCurve::OutQuart);
    QTimeLine *RightTimerBack2   = newAnim(right2,-45,0,QEasingCurve::InQuart);



    scene->setSceneRect(0, 0, 940, 460);

    view.setCacheMode(QGraphicsView::CacheBackground);
    view.setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
    view.setScene(scene);
    view.resize(960, 480);
    view.show();

    QObject::connect(LeftTimerTo,   SIGNAL(finished()), LeftTimerReturn,  SLOT(start()));
    QObject::connect(LeftTimerReturn, SIGNAL(finished()), RightTimerTo,   SLOT(start()));
    QObject::connect(LeftTimerReturn, SIGNAL(finished()), RightTimerTo2,   SLOT(start()));
    QObject::connect(RightTimerTo,  SIGNAL(finished()), RightTimerBack, SLOT(start()));
    QObject::connect(RightTimerTo2,  SIGNAL(finished()), RightTimerBack2, SLOT(start()));
    QObject::connect(RightTimerBack,SIGNAL(finished()), LeftTimerTo,    SLOT(start()));

    LeftTimerReturn->start();

    return app.exec();
}
开发者ID:Xambey,项目名称:learning,代码行数:53,代码来源:main.cpp

示例12: 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

示例13: updateOpacity

 void updateOpacity()
 {
     QPoint pos = q->parentWidget()->mapFromGlobal(QCursor::pos());
     QRect opaqueRect = q->geometry();
     bool opaqueCollapser = opaqueRect.contains(pos);
     int frame = mOpacityTimeLine->currentFrame();
     if (opaqueCollapser && frame == mOpacityTimeLine->startFrame()) {
         mOpacityTimeLine->setDirection(QTimeLine::Forward);
         startTimeLine();
     } else if (!opaqueCollapser && frame == mOpacityTimeLine->endFrame()) {
         mOpacityTimeLine->setDirection(QTimeLine::Backward);
         startTimeLine();
     }
 }
开发者ID:KDE,项目名称:libksane,代码行数:14,代码来源:splittercollapser.cpp

示例14: setPixmap

animate::animate()
{
     setPixmap(QPixmap(":/animate/dancer/dancer_2a1.png"));

     QTimeLine *timeline = new QTimeLine(2000);

     timeline->setFrameRange(0,16);

     connect(timeline,SIGNAL(frameChanged(int)),SLOT(setpic(int)));

     timeline->start();



}
开发者ID:F74041111,项目名称:pd2-Taiko,代码行数:15,代码来源:Animate.cpp

示例15: QTimeLine

void MyQGraphicsView::wheelEvent ( QWheelEvent * event )
{
    int numDegrees = event->delta() / 8;
    int numSteps = numDegrees / 15;  // see QWheelEvent documentation
    _numScheduledScalings += numSteps;
    if (_numScheduledScalings * numSteps < 0)  // if user moved the wheel in another direction, we reset previously scheduled scalings
        _numScheduledScalings = numSteps;
 
    QTimeLine *anim = new QTimeLine(350, this);
    anim->setUpdateInterval(50);
 
    connect(anim, SIGNAL(valueChanged(qreal)), SLOT(scalingTime(qreal)));
    connect(anim, SIGNAL(finished()), SLOT(animFinished()));
    anim->start();
}
开发者ID:mBusaleh,项目名称:corobot,代码行数:15,代码来源:MyQGraphicsView.cpp


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