Multiple default constructors specified...

Hello,

I have an inherited class that essentially manages a Qt Window.

It is as follows (prototype below):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class QTMyOpenGLWindow : public QWindow, protected QOpenGLFunctions {

	Q_OBJECT

public:

public:

	explicit QTMyOpenGLWindow(OpenGLProgram* SupportedOpenGLProgram, TextDrawer* SupportedTextDrawer, bool AutoInitialize = true,	QWindow *parent = 0);
	explicit QTMyOpenGLWindow(bool AutoInitialize = true, QWindow *parent = 0);
	explicit QTMyOpenGLWindow(QWindow *parent = 0);
	
	~QTMyOpenGLWindow();

[...]


Now, I can understand the confusion of the compiler, but the functionality as I laid it out works for me (I can create the class with just specifying the parent and also have the option of preventing auto-initialization when creating).

But, is there a better approach?

Thank you for your time.
If you don'#t specify an arg, you'll match the 2nd and 3rd constructors. But do you really need the 3rd one?
Not sure; I just see all of the QT documentation have this sort of constructor. I will try that out then...
You misunderstand. If you don't specify any arguments when constructing, which constructor is the compiler supposed to call?

You need to be specific.

1
2
3
4
public:
	QTMyOpenGLWindow(OpenGLProgram*, TextDrawer*, ...);
	explicit QTMyOpenGLWindow(bool AutoInitialize, QWindow *parent = 0);
	explicit QTMyOpenGLWindow(QWindow *parent = 0);

(NB: you don't need explicit for anything that requires two or more arguments.)

Hope this helps.
Topic archived. No new replies allowed.