LinuxQuestions.org
Support LQ: Use code LQCO20 and save 20% on CrossOver Office
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
 
LinkBack Search this Thread
Old 02-09-2007, 08:15 PM   #1
Four
Member
 
Registered: Aug 2005
Posts: 298

Rep: Reputation: 30
qt4 programming


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
 
Old 02-09-2007, 08:30 PM   #2
Four
Member
 
Registered: Aug 2005
Posts: 298

Original Poster
Rep: Reputation: 30
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 08:50 PM.
 
Old 02-09-2007, 08:57 PM   #3
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu (x86), Debian (PPC)
Posts: 3,528

Rep: Reputation: 60
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.
 
Old 02-09-2007, 10:18 PM   #4
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,352

Rep: Reputation: 129Reputation: 129
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.
 
Old 02-10-2007, 09:15 AM   #5
Four
Member
 
Registered: Aug 2005
Posts: 298

Original Poster
Rep: Reputation: 30
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 .
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
IDEs with QT4 eantoranz Programming 9 11-16-2010 08:35 AM
qt3 together with qt4 marekjs Slackware 2 06-28-2006 07:16 AM
Compiling qt4 apps for non-qt4 linux, win, mac birdseye Programming 4 10-31-2005 04:45 AM
installing qt4 fakie_flip Programming 7 09-14-2005 09:04 PM
qt3 or qt4 crAckZ Programming 1 09-06-2005 05:08 PM


All times are GMT -5. The time now is 10:49 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
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration