PDA

View Full Version : Class type redifinition with promoted custom widgets



zeno06
14th June 2012, 16:15
hi,

I usually use a custom widget of my own that inherits from QGLWidget as a rendering area for OpenGL. In Qt designer, I put a placeholder for it in my GUI an promote it to my own widget. In my GUI, there are two widgets of this type, each showing a different visualization. Then, I wanted to popup one of these widgets out of the main GUI into a separate windows(*). To do this, I created a new QMainWindows in QtDesigner and moved one widget to it (cut and paste). Now, when I compile the program, it gives a compile error that the class of my custom widget (the one being used in two QMainWindows) is being re-defined. I read the docs of Qt and some internet contributions and understood that the compiler generates the code for the classes of the widgets being promoted to. So in my case, the widget is used twice in two QMainWindows. How can I tell the designer/compiler that these widgets are the same one, so that the class is only declared once.

Thanks,
Zeno


(*) The goal behind this is that I want to be able to shift this rendering widget to a second monitor and see it in the full-screen mode, while still being able to control the main GUI.

wysota
17th June 2012, 18:22
Maybe you just forgot about protecting your widget's header file from multiple inclusion?


#ifndef MY_WIDGET_H
#define MY_WIDGET_H
// ...
#endif

zeno06
18th June 2012, 11:58
Actually not. "#ifndef"s are already there.