Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Logic behind number of lines in QTextEdit
Forum Updated to NodeBB v4.3 + New Features

Logic behind number of lines in QTextEdit

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 673 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    psbhardwaj09gmail.com
    wrote on last edited by
    #1

    Hi,

    I have building a chat application. Messages are entered using QTextEdit and will be displaying in QListView using QTextDocument::drawContents(). Message consists of characters and emoticons. Below is the code used to display the message in QListView.

    @
    QTextDocument *doc = new QTextDocument();
    doc->setHtml(textMessage); // message to be displayed in QListView
    doc->drawContents(painter); //displays the textMessage in QListView
    painter->restore();
    @

    In QListView using doc->drawcontents the message with emoticons are displayed. By using SizeHint() I am setting the height of the QListView. But I am unable to find the proper height of the message that is displaying using QTextDocument::drawContents(). So I need to calculate the number of lines or height of the message which is getting displayed in QListView.

    Emoticons size is different from text size and emoticon is considered as different word both in QTextedit and QListView. QTextedit - WrapwordOrAnywhere works fine but my logic for Qlistview show some extra balnk lines or cilps the msg.
    Can somebody let me know how its calculated in QTextEdit so that I can use same logic in QListView

    Pardeep Sharma

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved