[Go] parsing qt resource file usage

Source: Internet
Author: User

Parsing qt Resource File usage

Transferred from: http://mobile.51cto.com/symbian-270121.htm

This article introduces the use of QT files in detail, and, like most GUI framework design tools, QT introduces a resource file system. It is used to easily compile some binaries (mostly picture files) into an executable program, eliminating the hassle of attaching other files when the application is republished.

This article describes the use of qt resource Files , and, like most GUI framework design tools,qt introduces a resource file system. It is used to easily compile some binaries (mostly picture files ) into an executable program, eliminating the hassle of attaching other files when the application is republished.

resource Files for Qt

is an XML text format with a suffix of. Qrc. To use resource files in a QT project, you need to add the following code to the. Pro Project file

    1. RESOURCES = FILE.QRC

When such a statement is added to the project file, the Qmake system automatically calls the RCC ( resource file compiler) to convert the FILE.QRC to Qrc_file.cpp and finally uses GCC for normal compilation.

Basic format for resource files

Take a look at a simple. QRC example

    1. Images/copy.png
    2. Images/cut.png
    3. Images/new.png
    4. Images/open.png
    5. Images/paste.png
    6. Images/save.png

The main part and the code between the other parts copied over it, here the "images/" is relative to the path of your resource file , and the format of the resource file is not related. Then you can use Qfile in your source code to access them, in this case, because it is a picture file, then you can also access them directly with Qimage, but preceded by the prefix ":/", in the form of

    1. Qimage (":/images/copy.png");

Alias for resource file

If you have more resource files and are placed in a deeper directory, you can simplify them by using aliases.

    1. Images/cut.png

When you have an alias, you can access it in the. cpp file by using an alias

    1. Qimage (":/cut-img.png");

Internationalization of resource files

Some resource files may use different resource files depending on the language in which they are used. can also be implemented by aliases and language options, I did not look at the code

    1. Cut.jpg
    2. Cut_fr.jpg

In the. CPP code that uses the above resources , different resource files can be accessed through the same statement qimage (":/cut.jpg"), depending on the system lang.

Summary:qt resource File usage content is finished, from the basic format of the resource file to the format of the resource file, a detailed introduction of the QT file. I hope this content is helpful to you, if you have a situation, you can leave a message.

[Go] parsing qt resource file usage

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.