LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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
 
Thread Tools
Old 02-09-2007, 09:15 PM   #1
Four
Member
 
Registered: Aug 2005
Posts: 283
Thanked: 0
qt4 programming


[Log in to get rid of this advertisement]
I recently got qt4 on kubuntu and ran into a problem compiling a hello world tutorial

Code:
g++ -c -pipe -g -Wall -W -D_REENTRANT  -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. -o main.o main.cpp
main.cpp: In function ‘int main(int, char**)’:
main.cpp:12: error: ‘class QApplication’ has no member named ‘setMainWidget’
make: *** [main.o] Error 1
What else do I need? I only downloaded the qt4 packages, I selected the qt4-dev package (or similar) when installing. Obviously other packages came with it like the one for qmake.

Thank you
Four is offline     Reply With Quote
Old 02-09-2007, 09:30 PM   #2
Four
Member
 
Registered: Aug 2005
Posts: 283
Thanked: 0

Original Poster
I noticed the tutorial is for 3.0 I read the documentation for 4.0 and fixed the problem. It turns out that function is no longer supported and is handled slightly differently see here for details (QApplication section)

Nextly how do I compile an optomized version of QT. At school by default the qmake generates a make file that sets -O2 and other related optimizations. But for me at home I get the qt debuging libraries instead. Which is ok, but I want to be able to change qmake some how to produce optomized code (But not neccessarly by default). How do I do this?

qmake --help provided no helpfull resources on this (or atleast of what I understood)

Edit:
Sorry about this thread. Well anyway (Iam a newb with qt ) I found out how to do it. qmake documentation was not first on google but I found it. To make it put optimizations just do in the project file

CONFIG -= debug
CONFIG += release
and it will do the trick .

The docs are here (QT 3.1) however usable usable for 4.0. I don't know how much is changed.
Thank you.

Last edited by Four; 02-09-2007 at 09:50 PM..
Four is offline     Reply With Quote
Old 02-09-2007, 09:57 PM   #3
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu (x86), Debian (PPC)
Posts: 3,495
Thanked: 6
I think all you need to do it add/remove a line in the yourproject.pro, like this:
Code:
CONFIG += qt debug
If this exists, you get debugging compilation options, else not. You need to re-run qmake after the change.
matthewg42 is offline     Reply With Quote
Old 02-09-2007, 11:18 PM   #4
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 11
Posts: 1,860
Thanked: 26
There are a lot of differences between QT 3 and QT 4.So I would suggest that you point your browser at the QT 4 documentation. Or even better, install the QT4 documentation on your computer.
graemef is offline     Reply With Quote
Old 02-10-2007, 10:15 AM   #5
Four
Member
 
Registered: Aug 2005
Posts: 283
Thanked: 0

Original Poster
Thanks.

This is cool I can't wait to start utilizing OpenGL in QT. Soon I will make things that I can share with all my windows and linux friends .
Four is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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
qt3 together with qt4 marekjs Slackware 2 06-28-2006 08:16 AM
IDEs with QT4 eantoranz Programming 7 02-28-2006 10:23 AM
Compiling qt4 apps for non-qt4 linux, win, mac birdseye Programming 4 10-31-2005 05:45 AM
installing qt4 fakie_flip Programming 7 09-14-2005 10:04 PM
qt3 or qt4 crAckZ Programming 1 09-06-2005 06:08 PM


All times are GMT -5. The time now is 08:28 AM.

Main Menu
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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration