PDA

View Full Version : Grid Problem



merry
6th June 2007, 06:28
Hi All

I m working on QT4.2 on my Intel MAC ,

I had made a grid of 16x16 i.e. 16 rows and 16 columns on a widget with the help of Qt Programing.
And also used QPushbutton.
and
On click Event of the button Grid fills with the colour say RED.

But what I want is this when I clicks on the button the whole grid fills with the colour but slowly ,

that is It should be viewed that how whole grid is filled

i.e first it completes first row then second and so on...

for this I also used sleep and QTimerEvent but both doesnt works.

If anybody understands my Problem Then Pls help.

Thanx

Gopala Krishna
6th June 2007, 08:58
I am not sure whether this works properly but here is what came to my mind. I assume Grid is a widget since you didn't furnish these details.


class Grid : public QWidget
{
Q_OBJECT
public:
Grid(QWidget *par) : QWidget(par)
{
curRow = 0;
curCol = 0;
timer = new QTimer(this);
timer.setSingleShot(true);
connect(timer,SIGNAL(timeout()),this,SLOT(fillGrid ()));
}

public slots:
// This slot connected to push button's clicked signal
void fillGrids()
{
timer.start(100);
}

void fillGrid()
{
grid[curRow][curCol].fill(); // This is just pseudo code
curRow++,curCol++;
if(curRow >= MAX_ROWS || curCol >= MAX_COLS)
return;
timer.start(100);
}
...
}

I may be wrong since I cant test this at the moment. Please do correct me if anything is wrong.

merry
6th June 2007, 10:40
Thanx for the help

But with the use of QTimer, It works the same as it works before. On a single click of the button It fills the whole grid with the colour but with the difference , that after clicking on the button it wont displays anything until a mouse points over the widget.



thanx