How do I determine the height of a QTextDocument?

烂漫一生 提交于 2019-12-14 02:08:54

问题


Given a specific width, I want to find out the height of a QTextDocument. In other words, if the QTextEdit that contains the QTextDocument is w wide, what is its minimum height h in order to fully display the document without the need for scrollbars?


回答1:


Set the width for the QTextDocument object to your desired with and then call the function size().height(), this should return the height required for the width you have give it before. Have a look at the size() function documentation of QTextDocument class.

Hope it helps.



来源:https://stackoverflow.com/questions/3020559/how-do-i-determine-the-height-of-a-qtextdocument

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!