View Full Version : Suggestion needing regarding displaying large number of items one-by-one
qtzcute
17th August 2009, 20:52
Hi all,
Can anyone suggest me what will be an efficient way to generate approximately 100 qgraphics items (e.g. squares or rectangles) 'one-by-one'?
What i do now is that i just call an object of my class (responsible for generating the items) 100 times using a for-loop. But when i run my application all the items appear at the same time after a little pause.
What should i do to make them appear one-by-one?
:o
jsmith
18th August 2009, 16:00
start a timer.
call to display item when timer is elapsed say 100ms
qtzcute
18th August 2009, 17:05
Nah...timer isn't working for me. i create shapes by making object of my class named sqMap
...
...
square = new sqMap(tempWidth, tempHeight);
...
/*
QTimer *timer = new QTimer(this);
timer->start(1000);
*/
...
...
If timer is used nothing seems to happen. My shapes still not appearing one-by-one even if i set the timer to 10000. It seems like the timer is not working in first place because i get output very early than 10000 msec.
Am i using the timer wrongly?
Is there any other way?
Will QThread do the magic?
Thanks
Boron
18th August 2009, 19:09
You should connect the timers' signal timeout() to a slot that displays the newly created item.
qtzcute
18th August 2009, 19:53
Still no success. All items appear at a same time. :(
Following is a snippet from my code.
for(int j = 0; j < 200 ; j++)
{
...
...
makeAshape(tempWidth,tempHeight,j);
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(makeAshape()));
timer->start(1000);
...
...
}
void MainWindow::makeAshape(double tempWidth, double tempHeight, int j)
{
square = new sqMap(tempWidth, tempHeight, processInfoVector[j], tableView_processInfo, tableView_filesInfo);
}
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.