Qt Extended Home · Build System Home · Reference · User Guide · Internals codeless banner

Create a new project file

The example create_a_pro_file can be used as a hands-on example of how to create a project file.

Start by copying it somewhere and generating a basic qbuild.pro file using qbuild -project.

    qbuild -project

This will create a file qbuild.pro with contents similar to the following.

    TEMPLATE=app
    TARGET=example

    CONFIG+=qtopia quicklaunch

    # I18n info
    STRING_LANGUAGE=en_US
    LANGUAGES=en_US

    # Package info
    pkg [
        name=example
        desc="No Description"
        license=Unknown
        version=1.0
        maintainer="Unknown <unknown@example.com>"
    ]

    # Input files
    FORMS=\
        examplebase.ui

    HEADERS=\
        example.h

    SOURCES=\
        main.cpp\
        example.cpp

    # Install rules
    target [
        hint=sxe
        domain=untrusted
    ]

    desktop [
        hint=desktop
        files=example.desktop
        path=/apps/Applications
    ]

    pics [
        hint=pics
        files=pics/*
        path=/pics/example
    ]

    help [
        hint=help
        source=help
        files=*.html
    ]

This file is sufficient to build the application binary but it is missing many things that should be present for a well-behaved application.

Let's start by adding some internationalization information. Not strictly required but a good idea.

    # Specify the languages that make lupdate should produce .ts files for
    AVAILABLE_LANGUAGES=en_US
    # Specify the langauges we want to install translations for
    LANGUAGES=$$AVAILABLE_LANGUAGES

Then we need to install the .desktop file for the app to appear in the launcher.

    desktop.hint=nct desktop
    desktop.files=example.desktop
    desktop.path=/apps/Applications
    desktop.trtarget=create_a_pro_file-nct

This puts us in the Applications folder. Change the .path value to use another folder. Note that you need to perform extra steps to define new folders. See Create a launcher folder for more information.

The use of .trtarget and .hint=nct is optional but a good idea so that translations can be made.

Note that the .desktop file specifies the binary name (whatever TARGET is) and it specifies the same file for translations as the .trtarget value.

The .desktop file references a picture. We need to install it. It's best to use a general pictures directory to ensure icons and such are handled correctly.

    pics.hint=pics
    pics.files=pics/*
    pics.path=/pics/create_a_pro_file

Note the .path value. Installing images into a directory named the same as your TARGET ensures that there are no conflicts. The resource system also looks in this direcory first when trying to find images.

To satisy the online help requirement we'll install a help file.

    help.hint=help
    help.source=help
    help.files=create_a_pro_file.html

Again, note the use of the TARGET name here. Online help also looks at TARGET-<objname>.html for context-sensitive help. The object name of the toplevel window is used.

Finally we'll add some packaging information so that the application can be packaged.

    pkg.name=create_a_pro_file
    pkg.desc=Example Application
    pkg.version=1.0.0-1
    pkg.maintainer=My Company (www.mycompany.com)
    pkg.license=Commercial

See also Tasks and Project Files.


Copyright © 2009 Nokia
Qt Extended - Build System Documentation