Installation and Use of QT 5.1.0 (mingw)

Source: Internet
Author: User
Tags qt designer

Qt 5.1.0 (mingw) is installed and used as follows:

Install
Download QT 5.1.0 for Windows 32-bit (mingw 4.8, OpenGL, 666 MB). The installation package includes mingw 4.8 and QT creator 2.7.2. With the default settings, you can install them all the way.

use
now use QT creator to create a GUI application:
1. open QT creator and choose files create a file or project. .. ", select qt gui application . In the displayed dialog box, set the name to testqt , and specify " Create path ". Then go all the way to " finish ". Shows the automatically generated framework:
2. click the run button in the left column. The dialog box is displayed, as shown in:
3. you can switch to the release mode on the running button, as shown in:
4. after compiling in release mode, you can view the generated EXE Program in the folder, and use dependency Walker shows the DLL to be depended on to run this exe program, as shown in:
Finally, check the required DLL and put it in the directory where the EXE program is located, as shown in:
however, to run a program in an environment without QT installed, you also need qwindows. DLL File. Create a platforms folder and set qwindows. DLL in this folder.

Interface Design
Now try to use the QT designer design interface:
1. Double-click" Project "In the window" Interface file "Bottom" Mainwindow. UI ", You can enter the design mode, as shown in:

2. Add a menu bar. In the design window, the top prompt is" Enter ", Enter the name of the menu item. Each time you set a menu item ," Action Editor "An action is automatically added, as shown in:

Right-click the action and select" Go to the slot... ", Pop up" Switch to slot "Dialog box, select" Triggered () ", As shown in:

Press" OK ", The mainwindow class automatically adds the corresponding function, as shown in:

3. Compile and run, as shown in:

4. Add a toolbar. Because mainwindow already contains a toolbar, it will not be added. Add the above button directly. " Action Editor "Drag the action in the toolbar, as shown in:

Press Alt + Shift + R To quickly preview, as shown in the following figure:

5. Add a resource file. Switch to edit mode, right-click the project name, and select" Add new file... ", Pop up" Create a file "Dialog box, select" Qt resource file ", As shown in:

The name can be as follows: Test And then"Next step ", Directly press" Complete ", As shown in:

After that, add a prefix to the qrc file and click" Add "Button, select" Add prefix ", Fill in" /Res "(Other names are supported). This folder stores resources, as shown in:

Then, click" Add "Button, select" Add File ", Add all the resource files. The resource files here need to be placed in the project folder in advance, as shown in:

Here, you can set an alias for ease of use: Open . Then, save the resource file.
6. Switch to the design mode and double-click" Action Editor "Action in it, click"Icon "On the right" Select Resources ", As shown in:

Select the added open resource, as shown in:

In this preview, you can see that the "open" menu item has an icon added, and the button on the toolbar has become an icon, as shown in:

Learning materials:
1. QT Quick Start series tutorials

Http://bbs.qter.org/forum.php? MoD = viewthread & tid = 193.

2. QT learning path: from entry to mastery

Http://blog.51cto.com/zt/20

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.