如何使 QPlainTextEdit 看起来像一个 .txt 文件? [英] How to make QPlainTextEdit look like a .txt file?

查看:102
本文介绍了如何使 QPlainTextEdit 看起来像一个 .txt 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆