PDA

View Full Version : MVC - Abstract Widget Base Class - setupUI



SenSej
13th October 2008, 10:44
Hello,

I try to realize some kind of MVC.

My Mainwindow offers the slider, button etc to build up a graphical model.
Here you also can find an display area, included by an GroupBox with included layout named displayLayout.

I want to set up the posibillity to watch the model in this displayLayout area on one hand in 2D (by including an Painter Widget or an labelWidget which shows the an 2d image) and on the other hand in 3d (area with included QGLWidget).

When the model gets changed, i just want to say something like of "display->update()", without the need to know, if 2d or 3d mode is on or not. To do so, i set up an abstract interface base class called display. Class Display2d and Class Display3d are derived from Display. I want to include this base class by

Display* showSomething = new Disaply(GroupBox);
displayLayout->addWidget(showSomething);

2d just shows an image. 3D comes with own view control, as rotate and scale sliders to interact with the GL stuff. To realize the 3d interaction, i´ve use designer to create the slider within an ui_Display3dUI.

Now comes the problem. My clases are:

1. (abstract) class Display : public QWidget
2. class Display3d : public Display, private Ui::Display3dUI, public QGLWidget
3. 2d comes later

In constructor Display3d() i need to set up the UI stuff, by caling
setupUI(this);
and get the error:
`QWidget' is an ambiguous base of `Display3d'

My suggestion:
Base Display is typof QWidget,
Display3d is typeof Display and typeof QWidget, since QGWidget is derived from QWidget and
Display3d as child of Display is also an QWidget.
setupui( this ) can´f figure it out, which typof "this" is.

Anybody some hints?
Is it a good idea to derive QWidgets on my own, or should i use an already set up mechanism from qt? Are there any?

Thanks a lot in advance and thanks for your attention.