本文整理汇总了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();
}
示例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();
}
示例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);
}
示例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();
}
示例5: MarblePhysicsPrivate
MarblePhysicsPrivate( MarbleAbstractPresenter *presenter )
: m_presenter( presenter ),
m_mode( Instant ),
m_planetRadius( EARTH_RADIUS )
{
m_timeline.setDuration(2000);
m_timeline.setCurveShape( QTimeLine::EaseInOutCurve );
}
示例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)));
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}
示例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();
}
}
示例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();
}
示例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();
}