LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-26-2005, 05:07 AM   #1
sateeshgalla
LQ Newbie
 
Registered: Apr 2005
Location: Bangalore
Posts: 16

Rep: Reputation: 0
qt program compilation error


Hi all,

I wrote a simple program using Qt. The program is below.

#include <qapplication.h>
#include <qmainwindow.h>

int main(int argc, char **argv)
{
QApplication app(argc, argv);
QMainWindow window();
app.setMainWidget (window);
window.show();
return app.exec();
}

I compiled this program with following command.

g++ -o qt1 qt1.cpp -I$QTDIR/include -L$QTDIR/lib -lqt

When compiled with above commands i got the following error.

[root@localhost qt]# g++ -o qt1 qt1.cpp -I$QTDIR/include -L$QTDIR/lib -lqt
qt1.cpp: In function `int main(int, char**)':
qt1.cpp:8: error: no matching function for call to `QApplication::setMainWidget(QMainWindow (&)())'
/usr/lib/qt-3.3/include/qapplication.h:122: note: candidates are: virtual void QApplication::setMainWidget(QWidget*)
qt1.cpp:9: error: request for member `show' in `window', which is of non-class type `QMainWindow ()()'
[root@localhost qt]#


what might be the problem? Does any one has any idea?

when i typed "echo $QTDIR" i got
/usr/lib/qt-3.3

so any one has any solution?

Thanks in advance.

sateesh.
 
Old 08-26-2005, 05:33 AM   #2
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
qt1.cpp:8: error: no matching function for call to `QApplication::setMainWidget(QMainWindow (&())'

This is telling you that there's no setMainWidget() method in QApplication that takes a QMainWindow object as a parameter.

QApplication::setMainWidget(QWidget*)

That line is telling you that setMainWidget() takes a pointer to a QWidget as an argument, so you need to pass the address of a QWidget object (or one of a class that is derived from it, like QButton, QLabel for example) to that method.

You should have the Qt documentation on your system. On my machine, it's located in /usr/lib/qt-3.3.3/doc (but it might be different on yours). Have a look at the tutorial and the other stuff there (such as the class references).

Last edited by Nylex; 08-26-2005 at 05:45 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
gtk program compilation error RohanShrivastav Programming 5 02-16-2005 07:12 AM
c program compilation harun_acs Programming 3 03-18-2004 10:29 AM
Compilation of Program? drdroid Programming 5 12-09-2003 05:41 PM
GL program compilation woes PsychosisNode Programming 3 10-15-2003 10:18 PM
error during program compilation with RH7.1 Corinne Linux - Newbie 1 06-14-2001 08:25 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration