简体   繁体   English

QPlainTextEdit的文本宽度

[英]Text width of a QPlainTextEdit

I have a QPlainTextEdit widget that fills a portion of my window. 我有一个QPlainTextEdit小部件,它填充了我的窗口的一部分。 The user can resize the window, therefore the area consumed by the QPlainTextEdit widget can vary. 用户可以调整窗口的大小,因此QPlainTextEdit小部件占用的区域可以变化。

I would like to know how I can determine, at runtime, what are the maximum number of characters I can write to the text area before the horizontal scroll bar will appear. 我想知道如何在运行时确定在水平滚动条出现之前可以写入文本区域的最大字符数。

I am displaying columns of text that I will truncate to a maximum per column width. 我正在显示的文本列将被截断为每列最大宽度。 However, I only want to truncate columns if the total untruncated width of all columns will produce a scroll bar. 但是,我只想在所有列的总未截断宽度都会产生滚动条的情况下截断列。

In other words, if the total text doesn't fill the text area horizontally, there's no value in truncating any part of said text. 换句话说,如果整个文本没有水平填充文本区域,则截断所述文本的任何部分都没有价值。

使用QFontMetrics :: width可以帮助您确定文本的大小

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM