PDA

View Full Version : How can I get the number of lines to be used in qtextedit without the scroll bar? Thx



ThomasKwong
5th July 2012, 05:32
Hi All,

I'm the new blood on QT. I have a question on the class qtextedit. How can I know the max. number of lines that can be used in qtextedit without the scroll bar? That mean, I want to show the content as much as possible to the user who don't need to scroll up & down to see all message. Now, I think the calculation should be used for finding the max. line. The size of qtextedit can be found, but I can't find the exact size of text. It has a tolerance with +1 pixels by using textedit.fontMetrics().lineSpacing() .Also, I can't find the pixel distance at A as below. I can setup all correct factors for the calculation. Do any friends know how to calculation?

7950

Sorry for my bad English. As above case, I would like to show 2 lines, not 2.5 lines. If it is more than 2 lines, the rest of data are shown on the next qtextedit.

Thanks all,

Cheer,

Thomas

high_flyer
5th July 2012, 11:00
It has a tolerance with +1 pixels by using textedit.fontMetrics().lineSpacing()
What do you mean with "tolerance"?

chriskon149
9th July 2012, 06:26
It looks like you're displaying multiple strings (based on the text in the lines of your screenshot). How about using a QListWidget (it looks like you can use QListWidget::visualItemRect(const QListWidgetItem * item) to get each listed item's height and use the height of each item, which could be the same, to figure out how many items can fit within the edges of your QListWidget)?

I hope this helps!
Chris