Results 1 to 5 of 5

Thread: Put QWidget in a QTextEdit

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 334 Times in 317 Posts

    Default Re: Put QWidget in a QTextEdit

    My idea was to reimplement QTextCursor, QTextEdit, QTextDocument and QTextFrame in order to use a 'QTextWidget' class (derived from QTextFrame I have to create for this to work), or something like that; this class QTextWidget would simply be a container which can return a html string to describe the contained widget
    Isnt this what Qt Designer does ? Not exactly, but seems similiar..
    Whats your goal ? You can have a look at graphics view as well...
    Last edited by aamer4yu; 16th September 2009 at 07:19.

  2. #2
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    4
    Thanked 140 Times in 132 Posts

    Default Re: Put QWidget in a QTextEdit

    You could try combining Qt::WA_DontShowOnScreen with QWidget::render(). First one is a flag that makes your widget invisible, but with 'visible' porperty set to true - so you get all Paint events and so on. Now catch Paint events with some event filter or something and render your widget to pixmap, which you can place in QTextEdit. In this solution, every Paint event will fire QWidget::render() to render the actual widget state on the pixmap - just refresh it every time and you will have even blinking vista progressbar :]. Worse thing is with event handling - you have to catch for example mouse moves and clicks on you displayed pixmap and send them to the right part of your invisible widget.

    P.S. Try giving names to your classes diffrent than "Q..." as it can lead to some misunderstandings, and read your Qt license to see if it is allowed - i dont know, but check just in case
    Last edited by faldzip; 16th September 2009 at 13:01.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  3. #3
    Join Date
    Nov 2008
    Posts
    13
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    4

    Default Re: Put QWidget in a QTextEdit

    Thank you for your answers.

    My goal is to have n frames in the text, each contain a widget and can be handled by the user exactly like normal frames.

    Using a pixmap seems complicated, and with this I have widget in the QTextEdit, not in the text...

Similar Threads

  1. Adding a scrollbar to a QWidget
    By qtUser500 in forum Newbie
    Replies: 13
    Last Post: 2nd September 2009, 20:48
  2. Drawing on QTextEdit
    By jgrauman in forum Qt Programming
    Replies: 3
    Last Post: 7th February 2009, 10:40
  3. Replies: 0
    Last Post: 11th November 2008, 16:36
  4. Dynamic updates of a QWidget in a QScrollArea
    By plamkata in forum Qt Programming
    Replies: 2
    Last Post: 21st July 2008, 00:45
  5. QTextEdit, sizeHint, QWidget
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 3rd February 2007, 09:25

Tags for this Thread

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.