First
LinkedSliderDoubleSpinBox* constantFieldDirChanger = new LinkedSliderDoubleSpinBox is the dynamic allocation really necessary? (this ain't java)
|
I'm using GUI interfaces of Qt. The allocation isn't done like that directly, but rather the pointer is stored on the stack of the class, and the contents are stored on the heap. This is to have better control of this under the GUI if things have to get replaced or removed or so on.
(MainWindow*)parentWidget() wonder if that cast is necessary or safe
((MainWindow*)parentWidget())->openGLApp->blochsim->setConstantFieldDirection such a long chain could be a design flaw
|
(MainWindow*)parentWidget() is there because I want to access the MainWindow which is a parent of the current Dialog I'm doing this on. So the current dialog is defined as a class in MainWindow, and the "this" of MainWindow is passed upon the construction of the current dialog's object.
Please do not misunderstand what I'm trying to do. I want to call the function in its object stack. The functions are set and get functions!
I really don't understand. You pass those function, what is their purpose? They could not access anything inside the class so what you will be setting/getting ?
|
I'm using a slider and a spinbox together to change a variable inside the object blochsim. Since this is a GUI program, there is a nasty hierarchy I have to follow (that nasty chain) in order to access the object which has the variable to be changed.
The class contains the slider and the spinbox linked together, and the passed functions are the functions that change the variables when a change in the state of the slider or the spinbox occures.
Sorry if it wasn't clear, if it still not, please ask for more explanation. I can't be very objective when I'm thinking so hard about a problem :-)