本文整理汇总了C++中QTimeLine::setLoopCount方法的典型用法代码示例。如果您正苦于以下问题:C++ QTimeLine::setLoopCount方法的具体用法?C++ QTimeLine::setLoopCount怎么用?C++ QTimeLine::setLoopCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTimeLine
的用法示例。
在下文中一共展示了QTimeLine::setLoopCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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)));
}
示例2: 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);
}
示例3: QGraphicsRectItem
Pong::Pong()
{
this->setSceneRect(0, 0, WIDTH, HEIGHT);
this->p1 = new QGraphicsRectItem(0, 0,
PADDLE,
PADDLE*3);
this->p2 = new QGraphicsRectItem(0, 0,
PADDLE,
PADDLE*3);
this->p1->setPos(PADDLE, (HEIGHT-PADDLE*3)/2);
this->p2->setPos(WIDTH-PADDLE*2, (HEIGHT-PADDLE*3)/2);
this->p1->setBrush(QBrush(Qt::red));
this->p2->setBrush(QBrush(Qt::blue));
/* ball */
this->ball = new QGraphicsEllipseItem(0, 0, PADDLE, PADDLE);
this->ball->setPos((WIDTH-PADDLE)/2, (HEIGHT-PADDLE)/2);
this->ball->setBrush(QBrush(Qt::black));
this->setFocusItem(p1);
this->dx = -1;
this->dy = -1;
QTimeLine *timer = new QTimeLine(5000);
timer->setFrameRange(0, 100);
this->addItem(ball);
this->addItem(p1);
this->addItem(p2);
timer->setLoopCount(10000);
timer->start();
connect(timer,
SIGNAL(frameChanged(int)),
this,
SLOT(value_changed(int)));
}