Results 1 to 3 of 3

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

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2012
    Posts
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Question How can I get the number of lines to be used in qtextedit without the scroll bar? Thx

    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?

    62_.jpg

    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

  2. #2
    Join Date
    Aug 2011
    Location
    California, USA
    Posts
    24
    Thanks
    4
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How can I get the number of lines to be used in qtextedit without the scroll bar?

    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

Similar Threads

  1. Replies: 1
    Last Post: 5th March 2012, 06:34
  2. Replies: 0
    Last Post: 1st July 2010, 18:22
  3. how can I find number of lines in QTextedit ?
    By newplayer in forum Newbie
    Replies: 10
    Last Post: 14th August 2008, 23:02
  4. QTextEdit: how to get lines?
    By claudio in forum Qt Programming
    Replies: 2
    Last Post: 15th July 2007, 21:08
  5. Spaces between lines in QTextEdit
    By troorl_ua in forum Qt Programming
    Replies: 1
    Last Post: 3rd July 2007, 00:06

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.