Original link: https://ifmet.cn/posts/17760087/
Brief description: Created Qt QKeySequenceEdit shortcut key edit box, showing square garbled characters.

[TOC]
This article was originally published on ” Xie Zang’s Small Station “, and is reproduced here simultaneously.
analyze
 ? win10 21H2 ? Qt 5.12.11 ? Visual Studio 2019
 The reason for the garbled blocks of spoken words is usually to read GBK-encoded Chinese in UTF-8. Obviously, and having checked all encoding related, it’s not my fault at all, it’s a problem with new QKeySequenceEdit() .
PS: If you don’t understand the reason for garbled characters and how to solve them, please refer to the sixth part of QtExamples below, and extract two of them: Minimalism and Root Cause Exploration
- Ancient code, oral code, symbol code, question number, stick copy code
 - May the programming no longer be garbled (including Qt) – the root cause
 
solve
In the end, it was found that it was caused by mixing
 new QKeySequence ( Qt :: CTRL + Qt :: Key_Shift + Qt :: Key_Y ) // error 混用了
For correct usage, refer to Qt Assistant
 QKeySequence ( QKeySequence :: Print ) ; QKeySequence ( tr ( "Ctrl+P" ) ) ; // "+" 的左右不能有"空格" QKeySequence ( tr ( "Ctrl+p" ) ) ; QKeySequence ( Qt :: CTRL + Qt :: Key_P ) ;
 This article is reproduced from: https://ifmet.cn/posts/17760087/
 This site is for inclusion only, and the copyright belongs to the original author.