Qt Data Source System

Source: Internet
Author: User

Qt Resource System (how to use small images for icons) --- convert

1. Create a. qrc Resource Description file

For example, example. qrc:

<! Doctype RCC> <RCC version = "1.0">
<File> images/copy.png </File>
<File> images/cut.png </File>
<File> images/new.png </File>
<File> images/open.png </File>
<File> images/paste.png </File>
<File> images/save.png </File>

By default, the name used to access resources in an application is prefixed with/in the Resource description :/. For example:/images/cut.png. For other rules, see the QT document the QT resource system.

2. Use RCC to compile this file

RCC-binary myresource. qrc-O myresource. RCC

In this way, the compiled resource file is generated.

3. Use resource files

(1) register resource files
Qresource: registerresource ("/path/to/myresource. RCC ");

(2) When using resources, we can use the resource path to directly initialize the qicon, qimage, or qpixmap.
Cutact = new qaction (qicon (":/images/cut.png"), TR ("Cu & T"), this );

4. Compile Resources in the qmake pro File

1. Add it to the Pro File
Resources = application. qrc
Qmake generates a qrc_application.cpp file by using the rule. Qrc_application.cpp contains all the data and has been registered. You can directly use the resources in it.

All resources are arranged under a global resource tree.

5. Creating Resources in qdesigner is very simple.
(1) Select create a resource file. qrc in the resource manager window, and save the file.
(2) In the resource manager window, select Add Resource and file (the graphic file must be in the working directory and Its subdirectories), and then you can use the resource in the file.

6 Add in QT integrate vs 2003
A. qrc file is created when you create a new project. Double-click the file to open the resource configuration window. Configure the file in the configuration window. After the file is configured, you can directly use it in the code.


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.