Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
HOWTO: Make KDevelop ready for Qt4
View unanswered posts
View posts from last 24 hours

Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
Tux's lil' helper
Tux's lil' helper

Joined: 04 Jun 2004
Posts: 142
Location: Germany

PostPosted: Sat Apr 08, 2006 1:37 pm    Post subject: HOWTO: Make KDevelop ready for Qt4 Reply with quote

This howto tells you how to make kdevelop ready for Qt4. You can find all infos from this howto somewhere in the Qt docs and the kdevelop docs or in the forum, but it took me some time to figure out how to compile a Qt4 project, so I want to create a document with all necessary information in one place.

I assume that you have already emerged qt4 and that the qt3 tools are BEFORE the qt4 tools in your path. In this configuration you have to tell kdevelop explicitly to use the qt4 tools. For that purpose we will write a small start script which adjust the PATH variable for our need:



Be sure that QT4BIN points to a directory which contains qmake from Qt4. If you have found a qmake file and are not sure about its version, run it with the -v parameter.
Save the script, make it executable and run it from console or via "run command" in the Kde Menu.

After kdevelop has started, create a new qmake project. Despite the project name you can use the default settings in all steps.

Then, go to "Project Options" in the Project menu. In "C++-Specific" go to the Qt rider and enable the option "Use Qt in this project" and select Qt4.x as version. As long as I figured out, the option "Qt root path" shows no effect, so leave it alone.

Next, go to the "Code Completion" tab. Check all the boxes you like. I prefer to enable all available options.
That alone though is not enough to make code completion work. We have to import the Qt4 headers.
Click on "Add..." next to the list of code completion databases and select "KDevelop Custom Directory PCS Importer". In the next step enter "Qt4" as Database name and enter "/usr/include/qt4" in the text filed below "Directories to parse" and click the "Add" button. You are now ready for importing the headers. Click next and watch how KDevelop is parsing all the headers.
When it is finished, click "Finish" and make sure that the checkbox next to your new database is enabled. All others should be disabled if you intend to only use Qt4 in your project.

Save your settings by clicking ok and start coding ;)

If you use classes from modules different from QtCore or QtGui you have to tell the linker about your intentions. You do this by setting the QT variable in the .pro file for your project To make it persistent, open the qmake manager at the right of kdevelops window and enter the subproject settings for your default subproject (by default called "src"). Open the "Custom Variables" tab, click new and enter QT as name and the modules used by your project as value according to the table below. Seperate the entries with spaces, for example "core gui network". Be sure to click update after you have edited the fields!


Option     | Features
core       |  QtCore module (included by default)
gui        |  QtGui module (included by default)
network    |  QtNetwork module
opengl     |  QtOpenGL module
sql        |  QtSql module
svg        |  QtSvg module
xml        |  QtXml module
qt3support |  Qt3Support module

Even though core and gui are included by default, you must add them to the list because by setting the QT variable you override the default settings.

Before compiling your project one additional step is required. Once again, open the qmake manager, rightclick your subproject and select "run qmake" for each subproject.

You are now ready to compile via hitting F8 or selecting "Build Project" in the Build menu!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum