QT is released to solve audio and image and Chinese font garbled characters.

Source: Internet
Author: User

I published the QT version a few days ago and found that the image was not displayed. Later I found that there was no Image Library added! Find it and go to the QT installation package. I installed it on drive F:/QT/plugins and found plugins. There is

Imageformats is the image library, which contains jpg and GIF files. You can add images in that format! Note that you should test the imageformats folder to the current folder of your program! Add qapplication: addlibrarypath ("./plugins") to the main function ");

In this way, your release version with images will be ready!

Let's take a look at the DLL that is generally needed for the release version (usually generate release!

 

 

 

The Chinese font is garbled after it is published. The solution is similar to the image. Find plugins first, find codecs, and create the piugins folder in the current folder of your program, copy the codecs folder to the piugins folder and add it to the main function:

Qapplication: addlibrarypath ("./plugins ");

Qtextcodec: setcodecforlocale (qtextcodec: codecforname ("gb2312 "));
Qtextcodec: setcodecfortr (qtextcodec: codecforname ("gb2312 "));
Qtextcodec: setcodecforcstrings (qtextcodec: codecforname ("gb2312 "));

(Windows is gb2312; Linux is gb2312/UTF-8; arm board with UTF-8, and to set the font, generally with wenquanyi)

 

 

 

After finishing the picture and font, how can we add the sound? See the phonon_backend folder. This is the sound! First of all, let's explain the sound of QT. There are two ways to add sound in QT. The simplest thing is to use qsound,

Qsound A ("bomb.wav ");

A. Play ();

If you use qsound, you can simply use it without adding any more to the release version. However, this qsound does not seem to boast of the platform! It is not easy to use in Linux! (NAS is said to have to be installed, and it is difficult for me to install it! And the arm board cannot be installed !) So we have to use phonon. This phonon is quite tangled. I will talk about it for a moment, because it seems that this library is not available before qt4.5, and no phonon is used by default during cross-compilation, with it, compilation will cause many problems! Let's talk about windows first. poonon is very powerful. It can play audio and video files ~! After using phonon in the window, make the release version. First, you must go to F:/QT/bin to find

Put it in your executable program folder, and then go to F:/QT/plugins to find plugins,

Like the image, put phonon_backend in the folder of your executable program. Do not forget to add qapplication: addlibrarypath ("./plugins") in the main function ");

(If you do not add)

Let's take a look at the released version of all the images!

 

 

 

 

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.