Introduction to QT, installation and simple use example on Ubuntu14.04 32-bit

Source: Internet
Author: User
Tags qt designer

Qt is a cross-platform, C + + graphical user interface application Development framework. It can either develop GUI programs or be used to develop non-GUI programs. QT is an object-oriented framework that is easy to extend. Qt is a C + + toolkit that consists of hundreds of C + + classes that you can use in your program. QT has all the advantages of OOP.

The cross-platform QT contains about 15 modules, all of which are dependent on qtcore.

QT's compilation tools include: Configure, Qmake, Moc, Uic and RCC.

QT development tools include: Qt Creator, Qt Designer, Qt Assistant, QT linguist.

QT Basic module: (1), the basic module of QTCORE,QT4, defines the non-GUI class of Qt core used by other modules, all other modules depend on the module, (2), Qtgui, defines the graphical user interface class, (3), Qtnetwork, defines the network programming class of QT; (4), Qtopengl, defines the OpenGL support class, (5), Qtsql, defines the class that accesses the database, (6), Qtsvg, defines the display and generation of the SVG class, (7), Qtdesigner, defines the class that processes the UI file directly in the application, It enables applications to build user interfaces at run time using UI files, (8), Qttest, and defines classes for unit testing of QT applications and libraries.

QT Creator is a lightweight, cross-platform, integrated development environment IDE developed with QT, which contains a suite of university tools for creating and testing Qt-based applications. Qt Creator includes a Project Generation Wizard, advanced C + + code Editor, tools for browsing files and classes, integrated Qt Designer, Qt Assistant, Qt linguist, graphical gdb debug front end, integrated qmake build tools, and more. QT Creator can be used alone or in a complete set of SDKs with QT libraries and development tools.

The following is an introduction to QT's installation steps and simple tests on the Ubuntu14.04 32-bit:

(1), from HTTP://MIRRORS.USTC.EDU.CN/QTPROJECT/OFFICIAL_RELEASES/QT/5.4/5.4.1/ Download the latest version of Qt-opensource-linux-x86-5.4.1.run;

(2), copy it to the/HOME/SPRING/QT directory;

(3), open the terminal, enter into the/HOME/SPRING/QT directory, execute./qt-opensource-linux-x86-5.4.1.run, then the dialog box will pop up, then the next can be installed successfully;

(4), open Qtcreatorr, create a new console project Testqt,file--New File or project---Projects application--> Qt console appli Cation:choose-NAME:TESTQT, Create in:/home/spring/qttest,next------and Finish;

(5), this console project, will default in the/HOME/SPRING/QTTEST/TESTQT directory generated three files: main.cpp, Testqt.pro, TestQt.pro.user;

(6), on the left at a glance, check the projects--> Edit build configuration option can choose whether the compilation is debug or release, run the project, you can generate a testqt execution file;

(7), modify the Main.cpp file, remove the QT-related functions, change it to the following statement, the operation is all right:

#include <iostream>using namespace Std;int main (int argc, char *argv[]) {    cout<< "Hello qt!" <<endl;}

(8), create dynamic library Testqtdll:file-->new File or Project-------Library--C + + library:choose--> Name:te Stqtdll, Create in:/home/spring/qttest, next---next-->finish; The relevant code for this dynamic library is as follows:

Testqtdll.h:

#ifndef testqtdll_h#define testqtdll_h#include "Testqtdll_global.h" Class Testqtdllshared_export TestQtDll{public:    Testqtdll ();    int Add (int a, int b);}; #endif//Testqtdll_h

Testqtdll.cpp:

#include "testqtdll.h" Testqtdll::testqtdll () {}int testqtdll::add (int a, int b) {    return (A + b);}

(9), add the Libtestqtdll.so library to the TESTQT project: Select the TESTQT project, right-and ADD library-and External library--> Select libtestqtdll.so ( Note that it is debug or release), Next--and Finish, at this time testqt each file content as follows, run everything right:

Main.cpp:

#include <iostream> #include ". /testqtdll/testqtdll.h "using namespace Std;int main (int argc, char *argv[]) {    int a = 2, b = 3;    Testqtdll test;    int c = Test. Add (A, b);    cout<< "sum =" <<c<<endl<< "OK!" <<endl;}

Testqt.pro:

#-------------------------------------------------# # Project created by Qtcreator 2015-04-07t00:41:06##------------ -------------------------------------QT       + = coreqt-=       Guitarget = testqtconfig   + = consoleconfig   -= App_bundletemplate = appsources + = main.cppunix:!macx:libs +-l$ $PWD/. /build-testqtdll-desktop_qt_5_4_1_gcc_32bit-debug/-ltestqtdllincludepath + + $ $PWD/.. /build-testqtdll-desktop_qt_5_4_1_gcc_32bit-debugdependpath + = $ $PWD/.. /build-testqtdll-desktop_qt_5_4_1_gcc_32bit-debugunix:!macx:libs + =-l$ $PWD/.. /build-testqtdll-desktop_qt_5_4_1_gcc_32bit-release/-ltestqtdllincludepath + + $ $PWD/.. /build-testqtdll-desktop_qt_5_4_1_gcc_32bit-releasedependpath + = $ $PWD/.. /build-testqtdll-desktop_qt_5_4_1_gcc_32bit-release


Introduction to QT, installation and simple use example on Ubuntu14.04 32-bit

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.