Qt is an object-oriented framework. It can display Chinese in Ubuntu, but it can not be displayed in Chinese when porting Qt to the development board. How to make Qt open? What is displayed on the board? The following small series will introduce you to the way Ubuntu Qt ported to the development board to display Chinese.
There are two main points for displaying Chinese. One is the encoding, but the font.
There are various arguments about the code online search, utf8 gbk gb2312, I use utf8.
The development board must also have a corresponding Chinese font to display Chinese, I Here in the Ubuntu 12.04 installation directory usr /share /fonts /truetype /wqy directory, copy this to the font library in the development board Qt library, pay attention to the Qt font path to the environment variable QT_QWS_FONTDIR = /opt /qt -4.8.4 /lib /fonts
Finally, the code in the main function to:
#include & ldquo; widget.h & rdquo;
#include QApplication
#include 《QTextCodec》
int main(int argc, char *argv[])
{
QApplication a(argc, Argv);
QTextCodec *codec = QTextCodec::codecForName(“utf8”);
QTextCodec::setCodecForLocale(codec);
QTextCodec::setCodecForCStrings(codec );
QTextCodec::setCodecForTr(codec);
QFont font;
font.setFamily((“wqy-microhei”));
Widget w;
w.setWindowFlags(Qt::FramelessWindowHint);
w.show();
return a.exec();
}
Use a tr macro such as ui-"statelabel-"setText(tr) when using (“The camera is already running!”))
This way, you can use Chinese fonts when running on the development board, and there will be no problems with font size and layout.
The above is the introduction of Linux Qt porting to the development board to display Chinese, mainly because there is no corresponding Chinese font in the development board, just import the Qt font path into the development board.
Ubuntu 12.04 has a lot of problems when installing Xen, in order to avoid the same mistakes in the i
The OOM killer mechanism is a mechanism for Linux to kill processes. If the process corrupts system
Do you know that one of the Linux system commands is a pppsetup command? Why is the
In the Linux system, to set the boot, it is necessary to implement it through code.
How to delete the specified file in swap
How to install boost library in Linux system
How to install virtualization tools in Linux llibvirt
Ubuntu installs Pacman package manager step
How Linux lists directories larger than the specified size
Little-known Unix command inventory
RedHat download and install JDK method
Solution for Lantern tool cannot be started under Linux system
Linux system prompts mount unknown when mounting U disk
Linux uses awk to implement multi-line merge instances
Linux error when reporting a scheduled task -bash:crontab:command?
Win8 open the system's own drawing program operation method
Win8 comes with Office office software
Several novel shortcuts/combination keys for Windows 7
Win7 desktop background is always modified how to lock it so that others can modify it at will
How to retrieve the Charms bar on the right side of the Windows10 desktop
How to set the computer power-on password on win7 system?
Microsoft released win10 SDK preview (with download address) built-in Win10 Mobile simulator