Results 1 to 8 of 8

Thread: How to clear the GridLayout

  1. #1
    Join Date
    May 2011
    Posts
    21
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Symbian S60

    Default How to clear the GridLayout

    hello friends

    Actually i have an GridLayout where i add array of buttons in the layout..now on next call when i again tried to add array of buttons in that layout than some of the buttons that are previously added are also display in the layout...so how is it possible to clear the layout on each call..if so how it can be done..please suggest me..

    regards
    rahul

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to clear the GridLayout

    Delete the widgets that are in the layout before adding new ones.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    May 2011
    Posts
    21
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Symbian S60

    Default Re: How to clear the GridLayout

    yeh i had write the code like that but its not working..

    for(int i=0;i<6;i++)
    {
    for(int j=0;j<7;j++)
    {

    controlsLayout->removeWidget(cellBut[i][j]);
    }
    }

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to clear the GridLayout

    What do you consider "not working"? removeWidget() doesn't delete the widget so it stays on the form right where it was, only that it is not managed by a layout anymore.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    May 2011
    Posts
    21
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Symbian S60

    Default Re: How to clear the GridLayout

    Actually it remove buttons at last row..but doesnt remove buttons at first row..

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to clear the GridLayout

    Try calling "delete" on the widget instead.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    May 2011
    Posts
    21
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Symbian S60

    Default Re: How to clear the GridLayout

    hello wysota

    how can i interact with each buttons that i have used in creating my custom
    calender means i want to say suppose i click one button than it will give
    all the information of that buttons ie in which month,which week ie
    sun,mon,tue..etc is shown in textBrowser.

    i have tried to done one thing..

    Qt Code:
    1. for(int i=0;i<6;i++)
    2. {
    3. for(int j=0;j<7;j++)
    4. {
    5. cellBut[i][j]=new QPushButton;
    6. connect(cellBut[i][j],SIGNAL(clicked()),this,SLOT(showDialog()));
    7. }
    8. }
    9. void MainWindow::showDialog()
    10. {
    11. txtDateDisplay->setText("Hello");
    12. }
    To copy to clipboard, switch view to plain text mode 

    now here on each button click i simply set a text hello in the txtDateDisplay..now if i want that on each button click i set the text that appear on button in txtDateDisplay than how should i do it..because here i cant pass arguments in SIGNAL(Clicked()) function..

    regards
    Rahul
    Last edited by wysota; 13th May 2011 at 09:23.

  8. #8
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: How to clear the GridLayout


Similar Threads

  1. Widget layout in GridLayout
    By Dato0011 in forum Qt Programming
    Replies: 8
    Last Post: 7th December 2009, 09:26
  2. QMdiArea with Gridlayout
    By ericV in forum Qt Programming
    Replies: 0
    Last Post: 14th September 2009, 11:26
  3. How to drop space in GridLayout ?
    By jackm in forum Qt Tools
    Replies: 2
    Last Post: 3rd October 2008, 03:06
  4. Adding item to GridLayout???
    By Kapil in forum Newbie
    Replies: 23
    Last Post: 7th April 2006, 11:26
  5. does gridlayout really lay out?
    By illuzioner in forum Newbie
    Replies: 2
    Last Post: 26th February 2006, 00: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.