Qt creator usage tips

Source: Internet
Author: User

Article

Created by flycarl in 21 dec 2010

Last edited by hamishwillee at 13 Jun 2012.

Contents

1 Overview

2. Code browsing

2.1 Locator (Locator)

3. code editing

4. breakpoint debugging

5. Platform management

6. Project Management

6.1 compile parameters (build)

6.2 run Parameters)

7 related links

Introduction


As an IDE developed by QT, QT creator supports qt development and qml development. It can take full advantage of the cross-platform features of QT. Here are some tips for using QT creator,


For more information about how to use QT creator, see the video: Introduction to QT creator.

Code browsing


There are many shortcut keys in edit view to help you locate the desired code.


F4 switches between header files and code

F2 switches between declarations and Implementations

CTRL + K open the locator (Locator)

CTRL + Shift + F open the global search box

CTRL + F open the search box on the current page

CTRL + scroll wheel scaling code

Locator (Locator)


Creatorlocator. PNG

Figure: Click Ctrl + k to open the locator in the lower left corner. The commands and functions are recorded in the locator. You do not need to remember the commands.

Enter the following characters and spaces in the locator and add the keywords you want to search for. You can quickly locate the characters in the Code and try again.


P view the file of the current project

C View class

M view Method

L directly go to the selected row number

? Index in help

Video Demonstration: Video


Code editing


In QT creator, choose tools> Options> environment> keybord from the menu bar.


Creatorkeyboard. PNG

Figure: shortcut key setting window. You can enter a keyword in the filter column to locate the function to be used or a specific key position.

The shortcut keys and combinations in QT creator are defined here. You can set shortcuts according to your habits. Reasonable Use of shortcuts will greatly improve the development efficiency. See: Seven Habits of efficient editing. It is worth mentioning that QT creator has built-in support for VIM. Friends who are used to VIM can choose to enable this function. The following lists the shortcut keys for some common functions in QT creator.


CTRL + space | Video]

CTRL +/comment or cancel the comment

Alt + press enter to quickly fix the problem. For example, add an implementation for the method in the header file, add a declaration in the header file for the implementation, and add multi-language support for the string. Try again.

CTRL + Shift + r right-click the menu 'refactor-> rename' to find and replace the specific characters of the current project. The class name or method name can be used to facilitate refactoring.

Select several lines of code, click tab, and several lines of code are indented at the same time.

Breakpoint debugging


On the code editing page, click the row number to set the breakpoint and run debug to enter the debugging mode. Supports convenient online debugging. Demonstrate the effect of breakpoint triggering when running the QT simulator.


Creatordebugbreak. PNG

Figure: breakpoint debugging demonstration

In addition to breakpoint debugging, you can also use the qdebug class of QT to output console information. The Code is as follows:

# Include <qdebug>

 

Qdebug () <"some ";

Int COUNT = 5;

Qdebug () <"a number" <count;

Qstring STR ("A string ");

Qdebug () <"A qstring" <STR;

You can also easily use qdebug to obtain logs: How to redirect the qdebug output to a file qdebug will be output in the application output window (Alt + 3) in both Debug and release modes ), it is very convenient to output data on various platforms, including online debugging.


Creatorqdebug. PNG

Figure: qdebug output

Platform management


In QT creator, choose tools> Options> qt4


On Windows, the platform configuration file is stored in c: \ Documents and Settings \ <your acount> \ Application Data \ Nokia \ qtcreator. ini.

Creatorplatform. PNG

Figure: Platform management page in Option


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.