Results 1 to 3 of 3

Thread: Text Edit rendering

  1. #1
    Join Date
    Mar 2009
    Posts
    1
    Platforms
    Windows

    Default Text Edit rendering

    Hallo,

    I want to render the contents of QTextEdit on a custom widget. Is it possible and how can i do it?

    The main problem is that i have a custom widget with own paintEvent() and want to support text editing operations on it using a text box area. But i dont want to redo everthing that QTextEdit provides.

    Thanks,
    VR

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Text Edit rendering

    take a look at this method
    void QTextDocument::drawContents ( QPainter * p, const QRectF & rect = QRectF() )
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Nov 2009
    Location
    Sacramento, CA
    Posts
    24
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Text Edit rendering

    Old post, but I am having problems with QTextEdit. I looked into QTextDocument::drawContents, but all that ever draws is the text. Where is the cursor???

    Qt Code:
    1. void TextEdit::paintEvent(QPaintEvent *e)
    2. {
    3. QPainter painter(viewport());
    4. document()->drawContents(&painter,viewport()->rect());
    5. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 10:49
  2. Character encoding in text edit and llne edit
    By greenvirag in forum Qt Programming
    Replies: 3
    Last Post: 20th January 2009, 09:45
  3. Replies: 1
    Last Post: 15th January 2009, 11:34
  4. how to read from text edit in QT4
    By iamjayanth in forum Qt Programming
    Replies: 3
    Last Post: 17th October 2008, 13:51
  5. Replies: 8
    Last Post: 15th May 2007, 10:21

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.