Results 1 to 3 of 3

Thread: Grid Problem

  1. #1
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Question Grid Problem

    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
    Always Believe in Urself
    Merry

  2. #2
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Grid Problem

    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.

    Qt Code:
    1. class Grid : public QWidget
    2. {
    3. Q_OBJECT
    4. public:
    5. Grid(QWidget *par) : QWidget(par)
    6. {
    7. curRow = 0;
    8. curCol = 0;
    9. timer = new QTimer(this);
    10. timer.setSingleShot(true);
    11. connect(timer,SIGNAL(timeout()),this,SLOT(fillGrid()));
    12. }
    13.  
    14. public slots:
    15. // This slot connected to push button's clicked signal
    16. void fillGrids()
    17. {
    18. timer.start(100);
    19. }
    20.  
    21. void fillGrid()
    22. {
    23. grid[curRow][curCol].fill(); // This is just pseudo code
    24. curRow++,curCol++;
    25. if(curRow >= MAX_ROWS || curCol >= MAX_COLS)
    26. return;
    27. timer.start(100);
    28. }
    29. ...
    30. }
    To copy to clipboard, switch view to plain text mode 

    I may be wrong since I cant test this at the moment. Please do correct me if anything is wrong.
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

  3. #3
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: Grid Problem

    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
    Always Believe in Urself
    Merry

Similar Threads

  1. QTimer problem ... it runs but never triggs
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 4th July 2006, 13:54
  2. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 13:45
  3. Problem with bitBlt
    By yellowmat in forum Newbie
    Replies: 1
    Last Post: 5th April 2006, 15:08
  4. fftw problem
    By lordy in forum General Programming
    Replies: 1
    Last Post: 16th March 2006, 22:36
  5. Replies: 16
    Last Post: 7th March 2006, 16:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.