Setting Up a Qbs Project

To use Qbs to build a project, you must create a .qbs file for the project. You can use Qt Creator to create a C or C++ project that is built with Qbs. For more information about Qbs, see the Qbs Manual.

The application is built using the default Qbs profile that is associated with the build and run kit. Qt Creator automatically creates a Qbs profile for each kit. You can edit the build profiles by adding new keys and values.

To check which Qbs version is being used, select Tools > Options > Qbs > Version Info.

Building Qbs

If you build Qt Creator yourself from the Qt Creator Git repository, you also need to fetch the Qbs submodule to get Qbs support:

  1. Fetch the Qbs submodule in your Qt Creator git checkout with git submodule update --init.
  2. Run qmake on Qt Creator and build Qt Creator again.

Building Applications with Qbs

To build your application with Qbs:

  1. Select File > New File or Project > Non-Qt Project > Plain C Project or Plain C++ Project > Choose.
  2. In the Project Location dialog, specify the name and location for the project and select Next.
  3. In the Define Build System dialog, select Qbs in the Build system field, and then select Next.
  4. In the Kit Selection dialog, select a build and run kit for the project, and then select Next.
  5. In the Project Management dialog, select Finish to create a Qbs project.

  6. Edit the .qbs file for you project. Usually, you must add the Depends item for a Qt application. For examples, see the examples directory in the qbs repository.
  7. Select Projects to specify Build Settings for the project.
  8. Select Build Steps > Details to specify build steps:

    1. In the Build variant field, select Debug to include debug symbols in the build for debugging the application and Release to create the final installation file.
    2. In the Parallel jobs field, specify the number of parallel jobs to use for building.
    3. Select the Enable QML debugging check box to debug Qt Quick application projects.

      Note: Debugging requires opening a socket at a well-known port, which presents a security risk. Anyone on the Internet could connect to the application that you are debugging and execute any JavaScript functions. Therefore, you must make sure that the port is properly protected by a firewall.

    4. In the Properties field, specify the properties to pass to the project. Use colons (:) to separate keys from values. For more information, see Modules in the Qbs Manual.
    5. In the Flags field:
      • Select Keep going to continue building when errors occur, if possible.
      • Select Show command lines to print actual command lines to the compile output pane instead of high-level descriptions.
      • Select Force probes to force re-execution of the configure scripts of Probes.
      • Select Install to copy artifacts to their install location after building them. This option is enabled by default.
      • Select Clean install root to remove the contents of the install root directory before the build starts.

    The Equivalent command line field displays the build command that is constructed based on the selected options.

  9. Select Clean Steps > Details to specify flags for the cleaning step.

    • Select Dry run to test cleaning without executing commands or making permanent changes to the build graph.
    • Select Keep going to continue cleaning when errors occur, if possible.

    The Equivalent command line field displays the clean command that is constructed based on the selected options.

  10. Select Build > Build Project to build the application.
  11. Click the (Run) button to deploy and run the application.

Editing Build Profiles

You can modify a build profile that is associated with a build and run kit by editing the values of the keys generated by Qt Creator and by adding new values:

  1. Select Tools > Options > Qbs.
  2. By default, Qbs profiles are stored in the qbs directory in the Qt Creator settings directory to ensure that different Qt Creator instances do not overwrite each other's profiles. If you only run one Qt Creator instance, you can store the profiles in the Qbs settings directory instead, by deselecting the Store profiles in Qt Creator settings directory check box.
  3. In the Kit field, select a build and run kit.
  4. Select Edit to edit the profile associated with the kit.
  5. Select Add to add keys and values to the profile or to modify existing values.
  6. In the Key column, spefify the key to add or modify as: <module_name>.<property_name>.
  7. In the Value column, specify a value as a JSON literal.
  8. Click OK.

The values that you have modified are displayed in red in the Profile properties field.

For a list of available keys and values, see the List of Modules in the Qbs Manual.

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.