passing variables in a QWidget constructor when programming with QTDesigner
Hello everyone,
i am programming in Qt Designer and i want during the QWidget::init() call to pass some variables of my own.. but QtDesigner does not give you anyway to tamper with the form constructor.. and i do not want to affect directly the generated .h and .cpp files under folder .ui/ since they can be overwritten. Is there somethng else i can do?
Nass
Re: passing variables in a QWidget constructor when programming with QTDesigner
Re: passing variables in a QWidget constructor when programming with QTDesigner
Maybe not the best way to do it, but pretty easy. You can write a public method for your Widget, and send your parameters when you call this special method. Maybe a little example can be better:
Code:
// Somewhere in code, create an instance of some widget
viewer = new Viewer(frame3D, "graf");
// we need to send X and Y dynamic sizes, so:
viewer->param(sizeX, sizeY);
// put 'viewer' on screen...
viewer->show();
//.................
Note that we call param() before actually showing the widget. This way
param executes just after construct, and after init(), but before the widget is shown.
Class Viewer, must have a public method param():
Code:
void Viewer::param(int X, int Y) {....}
Hope this aproach can help someone.