×
Namespaces

Variants
Actions
Revision as of 05:35, 1 April 2011 by hamishwillee (Talk | contribs)

Adding Files to a Qt Project in Eclipse (Carbide)

From Nokia Developer Wiki
Jump to: navigation, search

Adding Files to the Project in Qt


To add a file to a Qt project in Eclipse, two steps are necessary. First, the file has to be added to the workspace and secondly, the file has to be added to the .pro file.

B1.jpg


If you want to add e.g. a new source file to your project, open the File|New|Source File wizard and enter the file name. The Source Folder line edit specifies the workspace project where the file will be added. After clicking Finish, the project scope selector dialog pops up. This dialog shows all defined scopes of the project's .pro file as well as the variable to which the file can be added. In the case of a source file, the "Source Files" variable is shown, for a header file the "Header Files" variable is shown and so forth. Select the scope where the source file should be inserted and click OK.

Now, the new file is

a) added to the workspace and

b) appended to the "Source Files" variable in the .pro file.

Since the .pro file has been changed it is opened in the editor and marked as modified. So, remember to save the .pro file before starting the build.



Adding a Form File:

B2.jpg

For adding a Designer form file, open the File|New|Other... wizard and select Qt Designer Form which is located in the Qt Designer branch. After clicking Next the designer templates dialog appears. Then select the template and enter a file name. Adding Custom Form Templates The Qt Eclipse integration also allows you to add any .ui file to the templates wizard. For doing that, go to the plugins directory of Eclipse and then navigate to com.trolltech.qtcppdesigner\src\com\trolltech\qtcppdesigner\wizards\templates. There you'll find all currently available .ui template files. To add a new template, copy the template file along with a small preview icon in this directory and add the name of the template to the templates.txt file. For an example have a look at the already existing ones.

Adding a Qt Gui Class

The CDT Eclipse plugin offers a class wizard for adding a header and source file in one go. Qt provides a similar wizard which adds an .ui file as well. Also, the generated Qt class has already some widget specific code implemented.

Once the Qt Gui class wizard is invoked, enter the class name and the source folder if needed. You can also change the name of the .ui file and specify a widget template.

The above is the procedure how can we add files and templates to the widgets.

105 page views in the last 30 days.
×