hi,
my app has some balloons with alphabets A-Z as text. I dont want to repeat the balloon with same character,I retrieved items from scene to QList.after completion of all letters,my app has to halt.but in middle itself it is giving error of Assert failure index out of range.can anyone help in correction of error
my code:
void GraphicsScene::createBallon(void)
{
QList<QGraphicsItem *>itemno=items();
qsrand
(QTime(0,
0,
0).
secsTo(QTime::currentTime()));
int random = qrand() % 26;
for(int i=1;i<itemno.size();i++)
{
Ballon *temp=qgraphicsitem_cast<Ballon*>(itemno.at(i));
if(temp->getText()==str[random])
return;
}
Ballon *ball = new Ballon(str[random]);
ball->setPos(500 , 550);
addItem(ball);
if(itemno.size()>26)
interval->stop();
}
void GraphicsScene::createBallon(void)
{
QList<QGraphicsItem *>itemno=items();
qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
int random = qrand() % 26;
for(int i=1;i<itemno.size();i++)
{
Ballon *temp=qgraphicsitem_cast<Ballon*>(itemno.at(i));
if(temp->getText()==str[random])
return;
}
Ballon *ball = new Ballon(str[random]);
ball->setPos(500 , 550);
addItem(ball);
if(itemno.size()>26)
interval->stop();
}
To copy to clipboard, switch view to plain text mode
Bookmarks