Basic installation and configuration of QT under Linux system

Source: Internet
Author: User
Tags valgrind version control system netbeans

Qt Creator supports Chinese, starts faster than Eclipse, NetBeans, and has a better interface, and works well with input method FCITX (cursor following).

You can use the QT creator Contemporary Code Editor as a vim helper, the advantage of which is that Qt creator can automatically parse projects to form friendly, quick smart tips, and you can also work with the GDB front end (above) and the Valgrind Front (above) in Qt creator ( HD Large map of the project debugging and memory analysis, but makefile to write their own or with the autotools generated, this for the use of VIM programming students, should be familiar. Almost forget, the continuous press two times Alt+v shortcut to enter VIM edit mode (Fakevim), which should be very attractive to vim users. Of course, Qt creator defaults to support the mainstream version control system GIT/HG/SVN and so on.

You can also use Qt Creator as the IDE as a lightweight alternative to the Eclipse CDT, Netbeans for C + +, the Heavyweight IDE. You can create a new non-QT CMake automatically built project directly in the Qt Creator Wizard, which means you don't have to write makefile yourself, you can automatically generate it by "performing CMake" in Qt creator. Of course, you can also import a make-built project into Qt creator to compile and debug, such as Nginx.

1. Install QT Creator and infrastructure environment (for example, Ubuntu):

To install the base system Build Kit:

The code is as follows:

sudo apt-get-y install build-essential cmake valgrind

Download the latest version of the binary QT Creator (recommended using the QT4 built 2.8 series of QT Creator to better compatible with FCITX IME):

Http://mirrors.ustc.edu.cn/qtproject/official_releases/qtcreator/2.8/2.8.1/

No GUI programming, no need to install the QT SDK, there is no qmake and related QT Development Library, only to download the 60M Qt Creator, such as My next is:

The code is as follows:

Qt-creator-linux-x86_64-opensource-2.8.1.run

After downloading to give execution permissions, run Select installation directory installation can be installed in their own home directory.

Project configuration default storage location ~/.config/qtproject

You can customize the configuration file location by using parameter-settingspath, such as:

The code is as follows:

/home/eechen/qtcreator-2.8.1/bin/qtcreator-settingspath/home/eechen/qtcreator-2.8.1

Note: If you are using the QT Creator 3 series based on QT5, the IBUs input method plug-in is integrated by default, and for Fcitx plug-ins, you need to manually install the package fcitx-frontend-qt5. Then copy the Bin/plugins/platforminputcontexts directory of libfcitxplatforminputcontextplugin.so to QT Creator 3, for example: sudo apt-get install Fcitx-frontend-qt5

Ln-s/usr/lib/' Arch '-linux-gnu/qt5/plugins/platforminputcontexts/libfcitxplatforminputcontextplugin.so/png/dev/ qtcreator-3.2.1/bin/plugins/platforminputcontexts/

Restart Qtcreator, you can normally use the Fcitx input method.

2, the automatic completion of the shortcut key "Ctrl + Space" to "alt+/" or "Shift+return" (return means enter key)

Tools-Options-environment-keyboard: Keyboard shortcuts to enter "Ctrl + Space", click X in the key sequence to delete the original "Ctrl + Space", enter the new "alt+/", OK exit.

3, in QT Creator use make to build, run, debug the common C + + project

FILE-new file or project-Import project-Import existing Project

This imported project is built with make, needs to write makefile files to build, support automatic completion, support debugging and memory analysis.

4, in QT Creator use CMake constructs, runs, the debugging general-purpose-C + + project

FILE-new file or project-Non QT Project: Create a new CMake project

In the parameters for the "perform cmake" step, fill in the-dcmake_build_type=debug

This allows you to debug your program in Qt Creator, and the-dcmake_build_type value can be set to debug or release or Relwithdebinfo.

CMake can automatically generate makefile to build projects with make, but building projects with CMake must also write CMakeLists.txt files.

Qt Creator supports building projects with Qmake,make,cmake, but cannot add files directly to CMake projects, and QT creator support for CMake has yet to be improved.

Temporarily, switch to File Manager to add files, and then right-click the project "execute CMake" to make parsing (parsing) effective and load files into the project.

5, Qt Creator will automatically identify the system installed GCC, g++, GDB, make, CMake, Valgrind, you can also go to the menu "tool"-> "Options" in some custom configuration.

Configure VIM External editor:

Tools-> Options-> Environment-> External tools-> use VI for editing

Change the xterm to Konsole or gnome-terminal.

parameter to-e vim "%{currentdocument:filepath}"

Configuration Terminal:

Tool-> Option-> Environment-> Overview

The KDE environment defaults to

The code is as follows:

/usr/bin/konsole-e

If you want to use Gnome-terminal, set to/usr/bin/gnome-terminal-x

To set up a program to run in a terminal:

Item (sidebar)-run-tick "run in terminal"

The "Ptrace operation not permitted" problem solution occurs when debugging (GDB):

Temporary settings:

The code is as follows:

sudo sysctl kernel.yama.ptrace_scope=0

Permanent settings: Edit/etc/sysctl.d/10-ptrace.conf change to Kernel.yama.ptrace_scope = 0

The system defaults to 1 for security, preventing user programs (such as GDB here) from accessing data from other processes (such as the konsole,gnome-terminal) memory.

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.