本文整理汇总了C++中QTimeLine::start方法的典型用法代码示例。如果您正苦于以下问题:C++ QTimeLine::start方法的具体用法?C++ QTimeLine::start怎么用?C++ QTimeLine::start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTimeLine
的用法示例。
在下文中一共展示了QTimeLine::start方法的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: movItemPos
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: 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();
}
示例4: 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)));
}
示例5: animate
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();
}
示例6: wheelAction
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();
}
示例7: animationStart
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: startAnimation
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: 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();
}
示例10: wheelEvent
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();
}
示例11: 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();
}
示例12: zoom
void PathologyViewer::zoom(float numSteps) {
if (!_img) {
return;
}
_numScheduledScalings += numSteps;
if (_numScheduledScalings * numSteps < 0) {
_numScheduledScalings = numSteps;
}
QTimeLine *anim = new QTimeLine(300, this);
anim->setUpdateInterval(5);
connect(anim, SIGNAL(valueChanged(qreal)), SLOT(scalingTime(qreal)));
connect(anim, SIGNAL(finished()), SLOT(zoomFinished()));
anim->start();
}
示例13: smoothScrollTo
void smoothScrollTo(const QModelIndex& index)
{
if (!index.isValid()) {
return;
}
const QRect rect = q->visualRect(index);
int oldValue = scrollBar()->value();
int newValue = scrollToValue(rect);
if (mTimeLine->state() == QTimeLine::Running) {
mTimeLine->stop();
}
mTimeLine->setFrameRange(oldValue, newValue);
mTimeLine->start();
}
示例14: 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);
}
示例15: UpDateStrategy
void GraphBase::UpDateStrategy(QString strategyName)
{
//存入原来的位置
this->mAnimationStartPosition.clear();
for (NodeBase *node : mNodes)
{
node->setFlag(QGraphicsItem::ItemSendsScenePositionChanges, false);
mAnimationStartPosition.push_back(node->scenePos());
}
if (strategyName == "Circular")
{
vtkSmartPointer<vtkCircularLayoutStrategy> circularStrategy
= vtkSmartPointer<vtkCircularLayoutStrategy>::New();
mStoredLayout->SetLayoutStrategy(circularStrategy);
}
if (strategyName == "ForceDirected")
{
vtkSmartPointer<vtkForceDirectedLayoutStrategy> forceStrategy
= vtkSmartPointer<vtkForceDirectedLayoutStrategy>::New();
mStoredLayout->SetLayoutStrategy(forceStrategy);
}
if (strategyName == "Fast2D")
{
vtkSmartPointer<vtkFast2DLayoutStrategy> fastStrategy
= vtkSmartPointer<vtkFast2DLayoutStrategy>::New();
mStoredLayout->SetLayoutStrategy(fastStrategy);
}
mStoredLayout->Update();
mOutPutGraph = mStoredLayout->GetOutput();
UpdateEndPosition(strategyName);
QTimeLine *animation = new QTimeLine();
animation->setUpdateInterval(50);
connect(animation, SIGNAL(valueChanged(qreal)), this, SLOT(OnAnimation(qreal)));
connect(animation, SIGNAL(finished()), this, SLOT(OnAnimationEnd()));
animation->start();
}