如何使 QPlainTextEdit 看起来像一个 .txt 文件? [英] How to make QPlainTextEdit look like a .txt file?
问题描述
我有一个 QPlainTextEdit,它以表格形式显示一些信息,并且我添加了将其另存为 .txt 文件的选项.我用 以了解如何便携地获取.
I have a QPlainTextEdit which shows some information in tabular form, and I added the option to save it as a .txt file. I built the table with prettytable. When I open the .txt file, it looks nice, just how I want it to look like. However, in my GUI, QPlainTextEdit shows it all unaligned. How can I make it look like in the .txt?
How I want it to look
How QPlainTextEdit shows it
First of all, there's no such a thing as "showing as a txt file", as txt files don't contain formatting information.
Anyway, what you actually want is to set the font of your QPlainTextEdit
to some fixed-width (or monospace) font; see this question to see how to obtain one portably.
这篇关于如何使 QPlainTextEdit 看起来像一个 .txt 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!