Results 1 to 5 of 5

Thread: Put QWidget in a QTextEdit

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

    Default Put QWidget in a QTextEdit

    Hello,


    I have a QTextEdit in which I want to put some QWidgets (for example, buttons, combo box, tab widget, etc...). 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 (string choosen by the programmer), so this class could be used in conjonction with a modified QTextCursor. But it appears to be very heavy...

    Have you other ideas ?

    In the case this idea is not bad, I have several questions :
    -which methods I should reimplement in QTextCursor and QTextDocument for this to work?
    -how to draw widgets when they're in a QTextWidget ? I've seen no drawing methods in QTextObject...

    Thank you in advance,

    Dartib

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

    Default Re: Put QWidget in a QTextEdit

    No idea(s) or comments ?

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

    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 06:19.

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

    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 12: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.

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

    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, 19:48
  2. Drawing on QTextEdit
    By jgrauman in forum Qt Programming
    Replies: 3
    Last Post: 7th February 2009, 09:40
  3. Replies: 0
    Last Post: 11th November 2008, 15:36
  4. Dynamic updates of a QWidget in a QScrollArea
    By plamkata in forum Qt Programming
    Replies: 2
    Last Post: 20th July 2008, 23:45
  5. QTextEdit, sizeHint, QWidget
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 3rd February 2007, 08: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.