PDA

View Full Version : custom widgets: passing new parameters to constructor (not only QWidget *parent)



mario-huizar
22nd April 2010, 10:09
Hello everyone,

I am trying to integrate a custom widget that I created. But I am having problems because my widget receives in its constructor no only the QWidget *parent but other parameters. I want it to integrate it into QT designer, either as a plugin or as a custom widget but I cannot find the way to tell QT Designer that it has more parameters in the constructor...

i.e. my custom widget constructor looks like this

EMI12Interface(AMManager *manager,QWidget *parent);

EMI12Interface is a QWidget but it receives no only a QWidget *parent in its construction but some other parameters...

At the time that I add my custom widget to QT Designer and QT Designer autogenerates my source file, my QWidget is created as :

eMI12Interface1 = new EMI12Interface( ECGWidget, "eMI12Interface1" );

and this are not the arguments that I want... How can I tell QT Designers to create my QWidget with other arguments?

Thanks for the help!
Mario

borisbn
22nd April 2010, 11:26
> How can I tell QT Designers to create my QWidget with other arguments?
I think, that you can't, because QDesigner doesn't know about value of argument, that it should set while calling your constructor.
You can:
1. Make a default value for your parameters, as this

MyClass( QWidget * parent, MyParamClass myParam = (), QString initString = "initialize" )
2. Make two constructors: with standard Qt's parameter QWidget * parent, and with your own parameters, and call the second if you're creating you class from code
3. Add function(s) to your class, that will set parameters (as Qt likes to do, for example: QFile( QString filename ) and QFile::setFileName( QString filename )

mario-huizar
22nd April 2010, 11:44
Yeah I think what I will do is to make one init() methode and this init() method will receive all the arguments that my class needs.