PDA

View Full Version : ambiguous call to overloaded function



:db:sStrong
9th February 2006, 11:21
hello there,

I am getting a kind of weired compiling error which says:


error C2668: 'testingQtMainWindow::testingQtMainWindow' : ambiguous call to overloaded function
Error executing cl.exe.

this is a simple test programme to make a main window with menu's. and the error is occuring in the main.cpp section of the programme. any idea's what i am doing wrong???

blackliteon
9th February 2006, 11:32
SOurce please...

:db:sStrong
9th February 2006, 13:55
this is the source and the error is occuring on line "5":


int main( int argc, char** argv )
{
QApplication app( argc, argv );

testWindow *tw = new testWindow();
tw->setCaption("test");
app.setMainWidget( tw );
tw->show();

app.connect(&app, SIGNAL(lastWindowClosed()),&app, SLOT(quit() ));
return app.exec();
}

zlatko
9th February 2006, 14:09
There is not enough code! Show header and implementation of your testWindow class.

blackliteon
9th February 2006, 14:29
this is the source and the error is occuring on line "5":


int main( int argc, char** argv )
{
QApplication app( argc, argv );

testWindow *tw = new testWindow();
tw->setCaption("test");
app.setMainWidget( tw );
tw->show();

app.connect(&app, SIGNAL(lastWindowClosed()),&app, SLOT(quit() ));
return app.exec();
}

testWindow - show include header of this class please

:db:sStrong
9th February 2006, 14:33
this is my header file:



#include <qmainwindow.h>

class QWorkspace;
class QTextEdit;

class testWindow : public QMainWindow
{
Q_OBJECT

public:
testWindow( QWidget* parent = 0, const char* name = 0, WFlags f = WType_TopLevel );
testWindow();
~testWindow();

protected:
QWorkspace *mdi;

protected slots:

void something();

private slots:


private:

};

and this is my implementation file:



#include "testwindow.h"

// here are othe qt header files.

testWindow::testWindow( QWidget* parent, const char* name, WFlags f )
: QMainWindow( parent, name, f )
{

//here comes my code
}

:db:sStrong
9th February 2006, 14:35
testWindow - show include header of this class please

include header of this class is:



#include <qapplication.h>
#include "testwindow.h"

jacek
9th February 2006, 14:39
testWindow( QWidget* parent = 0, const char* name = 0, WFlags f = WType_TopLevel );
testWindow();
Both of these constructors can be invoked without parameters and compiler doesn't know which one to choose. Do you need that second constructor?

zlatko
9th February 2006, 14:41
:D
you have decalre 2 empty constructor!

p.s. too slow:o
p.p.s. useless thread:o

:db:sStrong
9th February 2006, 14:41
oeps i found it :)

i got this warning:


multiple default constructors specified

and i have removed these lines:


testingWindow();
~testingWindow();

it works now fine..

thanx anyways guys

bye

:db:sStrong
9th February 2006, 14:42
:D
you have decalre 2 empty constructor!
yes i saw it ;) haha

Cesar
9th February 2006, 14:50
this is my header file:


#include <qmainwindow.h>

class QWorkspace;
class QTextEdit;

class testWindow : public QMainWindow
{
Q_OBJECT

public:
testWindow( QWidget* parent = 0, const char* name = 0, WFlags f = WType_TopLevel );
testWindow();
~testWindow();
//skip
};

Let's see...

testWindow *tw = new testWindow();
could be interpreted as both

testWindow *tw = new testWindow::testWindow();
and

testWindow *tw = new testWindow::testWindow(0, 0, WType_TopLevel);
That's why you get ambiguous call to overloaded function error. :)

:db:sStrong
9th February 2006, 16:17
:D
you have decalre 2 empty constructor!

p.s. too slow:o
p.p.s. useless thread:o

a thread can never be useless ;) sometimes u cant see the prob and small probs sometimes take much time

ESPASEBE(thanx in russian)

yop
9th February 2006, 17:42
...and i have removed these lines:

testingWindow();
~testingWindow();...Don't remove the destructor, the poor thing never caused you any harm :)

wysota
9th February 2006, 17:53
ESPASEBE(thanx in russian)

Не за что :)

:db:sStrong
10th February 2006, 10:27
Не за что :)

may i know what does it mean? :)

i can speak a little rusian but i cant read :(

Cesar
10th February 2006, 10:30
Не за что :)
means You're welcome! :)
Guys, I suppose we should avoid using Russian and stop confusing others ;)

zlatko
10th February 2006, 10:34
may i know what does it mean? :)

i can speak a little rusian but i cant read :(
:D not at all)

p.s. in ukraine language it sound better :cool:

:db:sStrong
10th February 2006, 10:36
:D not at all)

p.s. in ukraine language it sound better :cool:

i have been to ukraine, the language is totally different from russian :eek: Kiev is the best place to be :)