Results 1 to 6 of 6

Thread: Trying to refresh a QGridLayout

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2008
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Exclamation Trying to refresh a QGridLayout

    I've used Qt Designer to create a QWidget with a grid layout on it, containing checkboxes which are dynamically created in my code and correspond to a number in a file on my computer. When a file is changed on the machine, I need the layout to refresh with a number of check boxes equal to a new specified number in the file. I'm trying to use the following code:

    Qt Code:
    1. //Refresh the layout
    2. ui.TPCheckBoxLayout_G->invalidate();
    3. ui.TPCheckBoxLayout_G->activate();
    4. ui.TPCheckBoxLayout_G->update();
    5. QWidget::repaint();
    To copy to clipboard, switch view to plain text mode 
    I call this code right after I delete all of the items from the layout, using the following code:

    Qt Code:
    1. //Refresh checkboxes and buttons
    2. int rowCount = ui.TPCheckBoxLayout_G->rowCount();
    3. int columnCount = ui.TPCheckBoxLayout_G->columnCount();
    4. for(int i=0; i<rowCount; i++)
    5. {
    6. for(int j=0; j<columnCount; j++)
    7. {
    8. //Clear the TP layout
    9. ui.TPCheckBoxLayout_G->removeItem(ui.TPCheckBoxLayout_G->itemAtPosition(i,j));
    10. delete ui.TPCheckBoxLayout_G->itemAtPosition(i,j);
    11. }
    12. }
    13. }
    To copy to clipboard, switch view to plain text mode 
    However, after this code finished, the new boxes are present, but they appear over the old boxes, which don't exist in my code! My new stuff appears, but the old stuff doesn't go away. Any idea what I'm doing wrong?
    Last edited by jpn; 9th July 2008 at 18:16. Reason: missing [code] tags

Similar Threads

  1. Delete a QGridLayout and New QGridLayout at runtime
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 5th November 2007, 13:01
  2. Qt 3.3 QGridLayout
    By ToddAtWSU in forum Qt Programming
    Replies: 2
    Last Post: 23rd February 2007, 17:40
  3. Refresh QDataTable
    By shamik in forum Qt Programming
    Replies: 25
    Last Post: 1st December 2006, 05:04
  4. QGridLayout
    By ToddAtWSU in forum Qt Programming
    Replies: 5
    Last Post: 29th June 2006, 20:34
  5. QPixmap and QGridLayout
    By Talon_Karrde in forum Qt Programming
    Replies: 5
    Last Post: 22nd February 2006, 12:27

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.