Setting up the Eclipse QT development environment

Source: Internet
Author: User

1. Download eclipse
At present, the ECLIPSE+CDT can be integrated download, it seems to have been optimized, the speed is relatively fast.
The downloaded address is: http://www.eclipse.org/downloads/, select "Eclipse IDE for C + + developers" Download, the latest version is:

Http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/juno/R/eclipse-cpp-juno-win32.zip

2. Download MinGW
1) Automatic installation of MinGW
to the sitehttp://sourceforge.net/projects/mingw/files/, download the installation file.
after downloading, click Run mingw-get-inst-20120426.exe application, select the installation directory, it will automatically download the required files through the website. After installation, you need to set its directory to the system environment variable.

2) Manual installation of MinGW
to the website http://sourceforge.net/project/showfiles.php?group_id=2435, download the following installation package:
binutils-2.17.50-20070129-1.tar.gz
mingw-runtime-3.13.tar.gz
mingw-utils-0.3.tar.gz
mingw32-make-3.81-2.tar.gz
gcc-core-3.4.5-20060117-1.tar.gz
gcc-g++-3.4.5-20060117-1.tar.gz
w32api-3.10.tar.gz
Gdb-6.6.tar.tar

In order to reduce the decompression to a folder inside (decompression gdb, the file will be prompted to conflict, direct coverage can be).

3) Add the reduced decompression directory to the environment variable path
if the decompression to D:\MinGW, then add "D:\MinGW\bin" to the system directory.

3. Download qt and Eclipse plugins
to the QT website (Http://qt.nokia.com/products/eclipse-integration), download directly http://get.qt.nokia.com/qteclipse/qt-eclipse-integration-win32-1.6.1.exe, can be installed.


4. Install qt-eclipse-integration-win32-1.6.1.exe
You need to select the path to Eclipse and MinGW.


5. Development examples:
1). Set Eclipse
through the menu "window", "Preferences ...", go to the Parameter setting box and add the location and version number we just installed in Qt, such as:

2) Building QT Engineering
new Project, "File", "new"
Under qt directory, select "QT Gui Project", "Next", and then enter the project name, the rest of the only need to take the default value.

3) Add a button on the form
Double-click the UI file inside the project to open the Form editing window.
in the Menu "window", "Show View" , "other ..."
Select "Qt C + + Widget box", click "OK", you can open the control window, such as:

Open the Qt C + + Signal Slot Editor window in the same way.

4) Place two buttons on the window and right-click on the button to modify the objectname and text.
The two objectname were: "Button1", "Button2:".
text is: "Show box", "Close"



5) Add button event
in the Qt C + + Signal Slot Editor window, click the "+" icon and a line appears in the window.
Double -click, select Button2, double-click, select Clicked (), double-click, and select Close ().

Open the main window class header file (my is qqq.h) and add the Signal Response section and function:
Private Slots:
void on_button1_clicked ();

The format of this function must be:On_ Control Name _ Event type ()

inside the CPP file, add the header file and the function entity:
#include
...
void Qqq::on_button1_clicked ()
{
Qmessagebox box (this);
Box.settext ("Hello world!");
Box.exec ();
}

6) in Eclipse, compile and run the program.
The effect is as follows:



Note:
1. The default QT for MinGW installation, is not to install the debug library, if you want to run debug mode, the following method to compile the debug library,
in the QT bin directory, use the command:
Qtvars.bat Compile_debug
to compile the debug library.
requires approximately 3G of disk space, approximately 4 hours of compilation time.

2. If you finish installing Qt-eclipse-integration-win32-1.0.0.exe and find that the second time you start Eclipse is unsuccessful,
to Eclipse's plugins directory, delete the file "Com.trolltech.qtcppstartup_1.0.0.jar".

Reference: http://www.cnblogs.com/feisky/archive/2009/11/08/1598349.html

Related Article

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.