English French [qt-devnet.developpez.com] | EspaƱol

Qt Creator Whitepaper

Qt Creator is a complete integrated development environment (IDE) for creating applications with the Qt application framework. Qt is designed for developing applications and user interfaces once and deploying them across several desktop and mobile operating systems. This paper provides an introduction to Qt Creator and the features it provides to Qt developers during the application development life-cycle.

Introduction to Qt Creator

One of the major advantages of Qt Creator is that it allows a team of developers to share a project across different development platforms (Microsoft Windows®, Mac OS X®, and Linux®) with a common tool for development and debugging.

The main goal for Qt Creator is meeting the development needs of Qt developers who are looking for simplicity, usability, productivity, extendibility and openness, while aiming to lower the barrier of entry for newcomers to Qt. The key features of Qt Creator allow the developers to accomplish the following tasks:

  • Get started with Qt application development quickly and easily with project wizards, and quickly access recent projects and sessions.
  • Design Qt widget-based application user interface with the integrated editor, Qt Designer.
  • Develop applications with the advanced C++ code editor that provides new powerful features for completing code snippets, refactoring code, and viewing the outline of files (that is, the symbol hierarchy of a file).
  • Build, run, and deploy Qt projects that target multiple desktop and mobile platforms, such as Microsoft Windows, Mac OS X, Linux, Android, BlackBerry 10, embedded Linux, iOS, and QNX.
  • Debug with the GNU, CDB, and LLDB debuggers using a graphical user interface with increased awareness of Qt class structures.
  • Use code analysis tools to check for memory management issues in your applications.
  • Deploy applications to mobile devices and create application installation packages for that can be published in application stores and other channels.
  • Easily access information with the integrated context-sensitive Qt Help system.

Qt Creator is part of Qt Quick, which allows designers and developers to create the kind of intuitive, modern-looking, fluid user interfaces that are increasingly used on mobile phones, media players, set-top boxes and other portable devices. Qt Creator enables collaboration between designers and developers. Designers work in a visual environment, while developers work in a fullfeatured IDE, and Qt Creator supports round-trip iteration from design, to code, to test, and back to design. For more information about using Qt Quick to develop applications for mobile devices, see Qt Quick Tooling Whitepaper [qt-project.org].

Supported Operating Systems

Qt Creator installation packages are available for Microsoft Windows, Mac OS X, and Linux. Qt Creator can be run on other platforms, but that requires the compilation of the publicly available source code. Building and running Qt Creator from source code may require a separate installation of Qt on your computer.

For more information, see the Qt Reference Documentation [qt-project.org].

Working with Qt Creator

When you start Qt Creator, it opens to the Welcome mode, where you can open tutorials and example projects or start the project wizard to create your own projects.

Welcome mode.

Qt Creator meets its design goals of simplicity, ease-of-use, and productivity by relying on the concept of modes. These adapt the user interface to the different application development tasks at hand. Developers can use the mode selector or keyboard shortcuts to switch to a Qt Creator mode.

Each mode has its own view that shows only the information required for performing a given task and provides only the most relevant features and functions related to it. As a result, the majority of the Qt Creator window area is always dedicated to actual application development tasks.

Creating Projects

To be able to build and run applications, Qt Creator needs the same information as a compiler would need. This information is specified in the project build and run settings.

Setting up a new project in Qt Creator is aided by a wizard that guides developers step-by-step through the project creation process. In the first step, developers select the type of the project from the categories: Applications, Libraries, Non-Qt Project, or Other Project. Next, developers can select a location for the project and specify settings for it.

New Qt Widgets Application project wizard.

When the steps have been completed, Qt Creator automatically generates the project with required headers, source files, user interface descriptions and project files, as defined by the wizard.

Not only does the wizard help new users get up and running quickly, it also enables more experienced users to streamline their workflow for the creation of new projects. The convenient user interface makes it easier to ensure that a project begins with the correct configuration and dependencies.

Designing User Interface

Qt Creator provides a fully integrated visual editor, Qt Designer. Qt Designer is a tool for designing and building graphical user interfaces from Qt widgets. Users can compose and customize widgets or dialogs and test those using different styles and resolutions.

Widgets and forms created with Qt Designer are integrated seamlessly with programmed code, using the Qt signals and slots mechanism, which lets users easily assign behavior to graphical elements. All properties set in Qt Designer can be changed dynamically within the code. Furthermore, features such as widget promotion and custom plugins allow users to use their own widgets with Qt Designer.

Qt Designer is used for editing user interface files. It presents users with an intuitive drag-and-drop interface for composing new user interfaces. The user interfaces that are designed with Qt Designer are fully functional and can be previewed immediately to ensure that the design is as intended. There is no need to recompile the entire project to test out a new design. The following figure shows the integrated Qt Designer being used to edit a simple form.

The integrated Qt Designer.

The figure shows how Qt Designer is integrated into Qt Creator. The center of the view is used for the construction of the user interface, with the available user interface components (widgets) kept in the container on the left side of the window.

Other tools are positioned around the edge of the working area. These include the Object Inspector (top-right), which shows the hierarchy of the objects in the current user interface, and the Property Editor (right), used to configure the currently selected widget.

In addition, developers can use the integrated Qt Designer for many other tasks, such as connecting signals and slots, creating actions for toolbars and menus, and setting the tab order. The Qt Designer integration also includes project management and code completion.

Qt Designer is described in more detail in the Qt Designer Manual [qt-project.org].

Coding

Writing, editing and navigating in source code are core tasks in application development. Therefore, the code editor is one of the key components of Qt Creator. The code editor can be used in the Edit mode to write code.

The code editor in Edit mode.

The code editor offers a number of features that help developers maintain readability and coding style:

  • Syntax highlighting for keywords, symbols, and macros in C++ files. In addition, generic highlighting is supported for other types of files.
  • Code completion for elements, properties, ids and code snippets. This is also supported for developers’ own classes in the current project.
  • Checking code syntax and marking errors (with wavy underlining in red) while editing, making it unnecessary to use compilation simply as a way to find typos and syntax errors.
  • Auto-indentation for source code layout.
  • The ability to collapse and expand functions in the source code (code folding).
  • The Locator navigation tool for quick access to files, symbols, hierarchy, and other information.
  • Support for refactoring code to improve the internal quality or your application, its performance and extendibility, and code readability and maintainability, as well as to simplify code structure.

In addition to these features, the code editor has other useful features, such as:

  • Incremental search that highlights the matching strings in the window while typing. Advanced search allows you to search from currently open projects or files on the file system. In addition, you can search for symbols when you want to refactor code.
  • Line numbering and current line highlighting.
  • Easy commenting and uncommenting of code.
  • Quick switching between method definition and function declaration.
  • Bookmarks for easier navigation in the code.

The code editor supports different keyboard shortcuts for faster editing. It is possible to work without using the mouse at all, allowing developers to keep their hands on the keyboard and work more productively.

Building for Multiple Targets

Qt Creator provides support for building and running Qt applications for desktop environments (Windows, Linux, and Mac OS) and mobile devices (Android, BlackBerry 10, iOS, QNX).

The same source code built for and running on multiple targets.

Qt Creator allows developers to specify separate build settings for each development platform and to quickly switch between build targets. By default, shadow builds are used to keep the build specific files separate from the source. Developers can create separate versions of project files to keep platform-dependent code separate. They can use qmake scopes to select the file to process depending on which platform qmake is run on.

As well as providing support for qmake, Qt’s own build tool, Qt Creator also comes with support for CMake [cmake.org], a popular alternative. CMake is a cross-platform configuration and build tool that works with the native compiler toolchains on Microsoft Windows, Mac OS X, Linux and other platforms that the tool supports. Other alternatives are Autotools [gnu.org] and the Qt Build Suite – Qbs [qt-project.org].

Qbs is a new build tool for Qt. It is an all-in-one tool that generates a build graph from a high-level project description (like qmake or CMake do) and executes the commands in the low-level build graph (like make does). At the time of writing, Qbs is still experimental, but you can use it to build Qt Creator, for example.

Qt Creator also supports generic projects, where developers either use an unsupported build system, or do not want to associate a build system with their project at all. In cases like these, Qt Creator works as a code editor, and build settings can be manually specified for the project.

Debugging

Qt Creator is integrated with several external native debuggers: GNU Symbolic Debugger (GDB), Microsoft Console Debugger (CDB), the debugger of the low level virtual machine (LLVM) project, LLDB (still experimental at the time of writing), and an internal JavaScript debugger. The following figure shows Qt Creator in Debug mode with the debugging tools pane below the code editor.

In Debug mode, developers can perform common debugging tasks, including the following:

  • Interrupt program execution.
  • Step through the program line-by-line or instruction-by-instruction.
  • Set breakpoints.
  • Examine call stack contents.
  • Examine and modify registers and memory contents of the debugged program.
  • Examine and modify contents of local and global variables.
  • Examine the list of loaded shared libraries.
  • Disassemble sections of code.
  • Create snapshots of the current state of the debugged program and re-examine them later.

The Debug mode showing a breakpoint in the editor, as well as the call stack view and locals and expressions view.

Qt Creator displays the raw information provided by the native debuggers in a clear and concise manner. This simplifies the debugging process as much as possible without losing the power of the native debuggers.

In addition to the generic IDE functionality provided by stack view, views for locals and expressions, registers, and so on, Qt Creator includes features to make debugging Qt-based applications easy. The debugger plugin understands the internal layout of several Qt classes, as well as most containers of the C++ Standard Library and some GCC extensions. This deeper understanding is used to present objects of such classes in a useful way.

If Qt Creator is installed as part of Qt, the GNU Symbolic Debugger is installed automatically and developers should be ready to start debugging after they create a new project. However, they can change the setup to use debugging tools for Windows, for example.

Developers can connect mobile devices to the development PC and debug processes running on the devices.

Analyzing Code

The memory available on devices is limited and you should use it carefully. Qt Creator integrates Valgrind code analysis tools for detecting memory leaks and profiling function execution. You must download and install the Valgrind tools separately to use them from Qt Creator.

The QML Profiler is installed as part of Qt Creator. It allows you to profile your Qt Quick applications.

Using Version Control Systems

The recommended way to set up a project is to use a version control system. Only project source files should be stored. Files generated by the build system or Qt Creator should not be stored. Other approaches are possible, but we do not recommend using network resources, for example.

Qt Creator supports a number of version control systems, integrating their use into the working environment. Supported systems include Bazaar, ClearCase, CVS, Git (and several Git tools), Mercurial, Perforce, and Subversion.

Configuration is straightforward, with common settings for version control located together and features for specific version control systems located in Tools sub-menus.

Output for each system is shown in the Version Control output pane. User interface elements for displaying commits and managing repositories are also provided for some systems.

Getting Help

From time to time, developers may need further information about a certain class, function, or other part of the Qt API. All the Qt documentation and examples are accessible via Qt Help plugin in Qt Creator.

To view the documentation, the Help mode is used, where most of the window is devoted to the help text. While working with source code in Edit mode, developers can access context sensitive help by moving the text cursor to a Qt class or function and then press the F1 key. The documentation will be displayed within a panel on the right side of the code editor, as shown in the following figure.

Displaying context sensitive Qt Help information.

It is also possible to add external documentation to Qt Creator, complementing or replacing the existing documentation as required.

Summary

Qt Creator offers a complete development environment for Qt application creation. It is a lightweight tool with a strict focus on the needs of Qt developers, productivity, and usability.

Key features are the advanced C++ code editor and a graphical user interface for debugging C++ functions. Integrated Qt Designer, Qt Help, and the Locator tool for quick navigation, make Qt Creator the ideal environment for developing Qt applications.

The Qt Creator mode-centric way of working helps developers to focus on the task at hand by presenting only relevant user interface features to them.

Support for cross-platform build systems and version control software ensures that Qt Creator can be integrated fully into the working environment of a development team. In addition, Qt Quick tools for creating fluid user interfaces in close cooperation with the developers allow UI designers to join the team. For more information, see the Qt Quick Tooling Whitepaper [qt-project.org].

Qt Creator is available from Qt Project Downloads [qt-project.org].

This document is licensed under the Creative Commons Attribution-Share Alike 2.5 [creativecommons.org] license.

For more information, see http://creativecommons.org/licenses/by-sa/2.5/legalcode [creativecommons.org] for the full terms of the license.

Categories: