简体   繁体   English

为什么在QPlainTextEdit中输入时,光标的长度会改变?

[英]Why does the length of the cursor change when I input in QPlainTextEdit?

The length of the cursor changes when I input a word, and the length becomes the same as the word. 当我输入单词时,光标的长度发生变化,并且长度与单词相同。 How can I set QPlainTextEdit? 如何设置QPlainTextEdit?

self.setFont(QFont("Consolas", 10, QFont.Normal))

I set the css font family "Consolas", and when I input English words, there is no problem. 我将css字体系列设置为“ Consolas”,当我输入英语单词时,没有问题。 (I highlight the line number because when I get a screenshot the cursor disappear) (我突出显示行号,因为当我获得屏幕截图时,光标消失了)

第一张图片

But when I input Chinese word (this word is higher than English word), the problem comes. 但是当我输入中文单词(这个单词比英文单词高)时,问题就来了。

第二张图片

As you can see, the chinese word sinks (the height of the line became higher and the line sink): it is strange. 如您所见,中文单词下沉(行的高度变高,行下沉):这很奇怪。

第三张图片

The effect of above picture in Sublime Text is what I want. 我想要的是Sublime Text中上述图片的效果。

I think there is no problem with QPlainTextEdit . 我认为QPlainTextEdit没有问题。 You are seeing this problem because you are comparing Chinese letters with lower-case English letters: 您正在看到此问题,因为您正在将中文字母与小写英文字母进行比较:

Have a look: 看一看:

中国asdsd

These English letters look small as compared to Chinese ones, but: 与中文字母相比,这些英文字母看上去很小,但:

国中ASDFASD

In this case they look same sized. 在这种情况下,它们看起来大小相同。 Try it in your QPlainTextEdit , I tried it, everything is okay :) 在您的QPlainTextEdit尝试一下,我尝试了,一切都很好:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何更改QPlainTextEdit(Pyqt,PySide)的光标形状 - How to change cursor shape of QPlainTextEdit (Pyqt, PySide) QPlainTextEdit达到一定长度时运行方法 - run method when QPlainTextEdit at a certain length 为什么使用 tkinter 文本时光标粗细会发生变化? - Why does the cursor thickness change when using tkinter text? 为什么我的长度为 1 的字符串变为长度为 3? - Why does my string of length 1 change to length 3? 为什么即使我在循环中更改长度,Python 的“for”也会迭代列表的长度? - Why does Python's "for" iterate the length of the list even if I change the length in the loop? 当我在文本框中输入所需的长度时,为什么密码长度不会改变? - Why won't the password length change when I put the desired length in the textbox? 我可以在程序运行时更改raw_input光标的位置吗? -蟒蛇 - Can I change where the raw_input cursor is when the program is running? - python 使用 random.sample() 时,为什么我得到的值长度 (1) 与索引 (3) 的长度不匹配? - Why do I get Length of values (1) does not match length of index (3) when using random.sample()? 更改块大小时,为什么色调会改变? - Why does tone change when I change the block size? 为什么当我更改另一个列表时列表会发生变化? - Why does a list change when i change another?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM