Logic behind number of lines in QTextEdit

  • 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

    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

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.