The basic installation and configuration of QT in Linux system

Time:2021-4-19

QT creator supports Chinese, starts faster than eclipse and NetBeans, has a more beautiful interface, and works well with fcitx (cursor following).

You can use QT Creator as a code editor to assist vim. The advantage is that QT creator can automatically parse projects to form friendly and fast intelligent prompts. You can also use the GDB front-end (above) and Valgrind front-end (large HD) in QT creator Debugging and memory analysis of the project, but makefile will be written by itself or generated with Autotools, which should be familiar to the students who use VIM to program. Almost forgot, press Alt + V shortcut twice in a row to enter the VIM edit mode (fakevim), which should be very attractive to VIM users. Of course, QT creator supports git / Hg / SVN by default.

You can also use QT Creator as an IDE, which can be a lightweight alternative to eclipse CDT and NetBeans for C + +. You can directly create a new project in QT creator wizard that is not automatically built by QT using cmake. This means that you don’t have to write makefile yourself. You just need to “execute cmake” in QT creator to generate it automatically. Of course, you can also import a make built project to QT creator for compilation and debugging, such as nginx.

1. Install QT creator and infrastructure environment (take Ubuntu as an example)

To install the basic system build Kit:

Copy code

The code is as follows:

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

Download the latest version of binary QT creator (it is recommended to use QT4 based 2.8 series QT creator, which is more compatible with fcitx input method)

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

Without GUI programming, there is no need to install QT SDK, and there is no qmake and related Qt development library. Just download the 60m QT creator, for example:

Copy code

The code is as follows:

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

After downloading, give the execution permission, run and select the installation directory to install. You can install it in your home directory.

Default location of project configuration ~ /. Config / qtproject

You can customize the location of the configuration file through the parameter – settingspath, for example:

Copy code

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 QT creator 3 Series built on Qt5, it integrates IBus input method plug-in by default. For fcitx plug-in, you need to manually install fcitx-front-qt5, and then copy libfcitxplatfo rminputcontextplugin.so Go to the bin / plugins / platform input contexts directory of QT creator 3, such as sudo apt get install fcitx-front-qt5
ln -s /usr/lib/`arch`-linux-gnu/qt5/plugins/platforminputcontexts/libfcitxplatforminputcontextplugin.so /png/dev/qtcreator-3.2.1/bin/plugins/platforminputcontexts/
Restart qtreactor, you can use fcitx input method

2. Change the autocomplete shortcut “Ctrl + space” to “Alt + /” or “Shift + return” (return means enter)

Tools – Options – environment – keyboard: enter “Ctrl + space” as the keyboard shortcut, click X in the key sequence to delete the original “Ctrl + space”, enter a new “Alt + /”, and confirm to exit

3. Build, run and debug general C / C + + project with make in QT Creator

File – new file or project – import project – import existing project

The project imported in this way is built with make, which can only be built after the makefile is written. It supports automatic completion, debugging and memory analysis

4. Using cmake to build, run and debug general C / C + + project in QT Creator

File – new file or project – non QT project: create a new cmake project

Fill in – dcmake in the parameter of “execute cmake”_ BUILD_ TYPE=Debug

Only in this way can you debug the program in Qt Creator, -DCMAKE_BUILD_TYPE The value of can be set to debug or release or relethdebinfo

Cmake can generate makefile automatically, which is convenient to build projects with make, but you must be able to write projects with cmake CMakeLists.txt File

QT creator supports using qmake, make and cmake to build projects, but it can’t directly add files to cmake projects. QT creator’s support for cmake needs to be improved

The temporary method is to switch to the file manager to add the file, then right-click the project “execute cmake” to make parsing take effect, and load the file into the project

5. QT creator can automatically identify GCC, G + +, GDB, make, cmake and Valgrind installed in the system, and can also make some custom configurations in the menu “tools” > “options”

To configure the VIM external editor:

Tools > Options > environment > External Tools > Edit with Vi

Change xterm to Konsole or Gnome terminal

Change the parameter to – e VIM “% {curren” tDocument:FilePath }”

Configuration terminal:

Tools > Options > environment > summary

The KDE environment defaults to

Copy code

The code is as follows:

/usr/bin/konsole -e

If you want to use Gnome terminal, set it to / usr / bin / Gnome Terminal – X

Set to run the program on the terminal:

Project (sidebar) – run – check “run in terminal”

The problem of “ptrace operation not permitted” occurs during debugging (GDB). Solution:

Temporary settings:

Copy code

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 purpose of setting 1 by default is to prevent user programs (such as GDB) from accessing the memory data of other processes (such as Konsole, Gnome terminal)

Recommended Today

Envoy announced alpha version of native support for windows

Author: sunjay Bhatia Since 2016, porting envoy to the windows platform has been an important part of the projectOne of the goalsToday, we are excited to announce the alpha version of envoy’s windows native support. The contributor community has been working hard to bring the rich features of envoy to windows, which is another step […]