Problem description: In my program, I want to use the following code to change the prompt in the input field to “Please enter your password”. But the program error, unable to recognize Chinese characters.
QLineEdit *passwordEdit;
passwordEdit->setPlaceholderText("Enter your password please");
solution: use QString::fromLocal8Bit() method to transcode Chinese characters, the program can normally recognize Chinese character QString. Change the above code as follows:
QString str;
str=str.fromLocal8Bit("Enter your password please");
passwordEdit->setPlaceholderText(str);
another problem: program error “error C2001: newline in constant”
Problem analysis: The encoding mode of the code file Login. CPP is not correct. Changing the encoding mode of the file login. CPP to UTF-8 can solve this problem. The method I used to modify the encoding method of the file was to open the CPP file with notepad software and select the encoding form of the file in the “Save as” window:
After saving the file as UTF-8, reload the file and compile the program. The error disappears and the Chinese character can be displayed normally.
Read More:
- Solve the problem of using logback console to print log Chinese characters in IDEA as garbled characters
- Solution to the problem of Chinese garbled in gradle console in idea
- Generate template asp.net Cs1010: newline in constant
- Solving the problem of Chinese garbled code in qtring
- Solution to the problem that some special characters in finereport cannot be displayed or displayed as question mark
- Solution to the problem of no C / C + + option in the new project of eclipse
- Solution to the problem that listen TCP 0.0.0.0:3306: bind: address already in use port is occupied in Linux centos7
- Solution of Chinese garbled code when using QT
- error C2057: expected constant expression (Can the size of an array in C language be defined when the program is running?)
- How to use scanner to accept char type characters in Java
- Error C2664 in C + + compilation: cannot convert parameter 2 from “const char [5]” to “lpctstr” solution.
- Change the path in the user directory in Chinese Ubuntu to English
- After Oracle 11g is installed, SQL_ Plus.exe The problem of Chinese garbled in command window
- Solve the problem of Chinese garbled code of actibpm plug-in in idea
- Configuring OpenGL in Chinese version of VS2010 and problem solving
- Chinese garbled code when vscode calls CMD to run C / C + +
- Remove M Characters “Control M” or “^M” or “CTRL M” Characters in a UNIX file
- Error c2137 of C language: empty character constant (Fixed)
- Solution of Chinese display garbled code in Git Bash
- The problem of Chinese garbled data in MySQL