schall_l
7th August 2008, 15:06
Hi,
I have a layout filled with 2 widgets.
I would like to replace one of the widgets of the layout using a signal/slot mechanism.
What do I need to do so that the layout is repainted/refreshed using the new widget after the widget has been changed ?
DriverView::DriverView( QWidget* parent ) :
QWidget( parent )
{
// Title
title = new TitleFrame(this,"Actual Driver");
// Body
body = driverFactory()->driverUserInterface(driverFactory()->currentDriver());
// Layout
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(title);
mainLayout->addWidget(body);
mainLayout->setContentsMargins (0, 0, 0, 0);
setLayout(mainLayout);
connect(driverFactory(),SIGNAL(driverHasChanged()) , this, SLOT(refreshDriverView()));
}
void
DriverView::refreshDriverView() {
body = driverFactory()->driverUserInterface(driverFactory()->currentDriver());
// repaint(); doesn't work
// update(); doesn't work
}
I have a layout filled with 2 widgets.
I would like to replace one of the widgets of the layout using a signal/slot mechanism.
What do I need to do so that the layout is repainted/refreshed using the new widget after the widget has been changed ?
DriverView::DriverView( QWidget* parent ) :
QWidget( parent )
{
// Title
title = new TitleFrame(this,"Actual Driver");
// Body
body = driverFactory()->driverUserInterface(driverFactory()->currentDriver());
// Layout
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(title);
mainLayout->addWidget(body);
mainLayout->setContentsMargins (0, 0, 0, 0);
setLayout(mainLayout);
connect(driverFactory(),SIGNAL(driverHasChanged()) , this, SLOT(refreshDriverView()));
}
void
DriverView::refreshDriverView() {
body = driverFactory()->driverUserInterface(driverFactory()->currentDriver());
// repaint(); doesn't work
// update(); doesn't work
}