[Qt-interest] swap out "central" layout when button is pressed with new widgets

S. Aguinaga sa_jr at yahoo.com
Thu Jul 30 22:35:26 CEST 2009



I have a window with a central layout, when I press  a button in central widget, I want to remove this layout/widgets(?) and in the SLOT callback code populate the central area with a new set of Widgets ( or new layout, a form with QLineEdits, and labels and 1 or 2 buttons to 'save' and return').  But maybe this is in _general_ the wrong way of going about it!

I'm able to remove the central widget using either of the following lines in my callback SLOT function:

>CustomCentalWidget::close();
>or
>CustomCentralWidget::QWidget::hide();


But if I create a new QGroupBox and a QVBoxLayout and add widgets to this layout I can't get  them to show up.

References:
The button calling the _slot_ code:

CentralPage::CentralPage(QWidget *parent)
>    : QWidget(parent)
>{
>....
>connect( addExperimenterButton, SIGNAL( clicked() ), this,\
>             SLOT( addExperimenterSlot() ) );
>}

I have simplified the callback  code to see if I can get something to show up:
bool CentralPage::addExperimenterSlot(void)
>{
>    //CentralPage::QWidget::hide();
>    CentralPage::close();
>    
>    QPushButton *addExp2dbButton = new QPushButton(this, tr("Add") );
>    addExp2dbButton->show();
>    //this->show();
>
>>
>
>>
>    return 1;
>}
>
>
What I end up with is with an empty central widget: 
+------------------------+
| north Widget Group Box |
+------------------------+
|                        |
|   (central widget)     |
|                        |
+------------------------+
| South Widget Group     |
+------------------------+

So, 
1. How can I add new widgets to the central widget from a private/public SLOT?
2. Is what I want to do the right way of going about it?  

References:
Re: [Qt-interest] Problem with adding/removing/adding elements in a QVBoxLayout

________________________________


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090730/95a217da/attachment.html 


More information about the Qt-interest-old mailing list