ucomesdag
5th June 2006, 23:03
Hi, i was wondering if it is possible to initalize a child widget within the parent?
I tried to add it in the constructor of the parent, but then the child widgets is not shown...
In this case i want to initialize fx1 in the constructor of floorBoard... this to keep clean main.
#include "stompBox.h"
#include "floorBoard.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
floorBoard floor;
stompBox fx1(&floor);
fx1.setId(0);
fx1.setImage(":/images/fx1.png");
fx1.setPos(floor.getPos(0));
QComboBox *fx1_comboBox = new QComboBox(&fx1);
fx1_comboBox->addItem( "Test 1" );
fx1_comboBox->addItem( "Test 2" );
fx1_comboBox->addItem( "Test 3" );
fx1_comboBox->setGeometry(8, 31, 79, 13);
fx1_comboBox->setEditable(false);
fx1_comboBox->setFont(font);
fx1_comboBox->setPalette(pal);
fx1_comboBox->setFrame(false);
customButton fx1_button(false, QPoint::QPoint(4, 110), &fx1);
customLed fx1_led(false, QPoint::QPoint(41, 4), &fx1);
QObject::connect(&fx1_button, SIGNAL(valueChanged(bool)),
&fx1_led, SLOT(setValue(bool)));
floor.show();
return app.exec();
};
I tried to add it in the constructor of the parent, but then the child widgets is not shown...
In this case i want to initialize fx1 in the constructor of floorBoard... this to keep clean main.
#include "stompBox.h"
#include "floorBoard.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
floorBoard floor;
stompBox fx1(&floor);
fx1.setId(0);
fx1.setImage(":/images/fx1.png");
fx1.setPos(floor.getPos(0));
QComboBox *fx1_comboBox = new QComboBox(&fx1);
fx1_comboBox->addItem( "Test 1" );
fx1_comboBox->addItem( "Test 2" );
fx1_comboBox->addItem( "Test 3" );
fx1_comboBox->setGeometry(8, 31, 79, 13);
fx1_comboBox->setEditable(false);
fx1_comboBox->setFont(font);
fx1_comboBox->setPalette(pal);
fx1_comboBox->setFrame(false);
customButton fx1_button(false, QPoint::QPoint(4, 110), &fx1);
customLed fx1_led(false, QPoint::QPoint(41, 4), &fx1);
QObject::connect(&fx1_button, SIGNAL(valueChanged(bool)),
&fx1_led, SLOT(setValue(bool)));
floor.show();
return app.exec();
};