Results 1 to 6 of 6

Thread: how to draw a widget on another widget?

  1. #1
    Join Date
    Jun 2009
    Posts
    74
    Thanks
    23
    Thanked 2 Times in 2 Posts

    Default how to draw a widget on another widget?

    suppose I have a widget ,say, QTextEdit, it already has some corresponding attributes: text, font, color, ....
    I want to draw it onto a widget of my own

    how can I achieve that?

    //mywidget.h
    class MyWidget : public QWidget
    ...

    //mywidget.cpp
    void MyWidget :: paint()
    {
    //???
    }
    Last edited by hashb; 28th May 2012 at 06:14.

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: how to draw a widget on another widget?

    Make your custom widget as the parent of QTextEdit
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3
    Join Date
    Jun 2009
    Posts
    74
    Thanks
    23
    Thanked 2 Times in 2 Posts

    Default Re: how to draw a widget on another widget?

    Hi Santosh, Thanks
    it do works, but in some cases I have to PAINT an existing widget on my widget , any ideas about it ?

  4. #4
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: how to draw a widget on another widget?

    How does these two differ? I see both of them as same.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  5. #5
    Join Date
    Jun 2009
    Posts
    74
    Thanks
    23
    Thanked 2 Times in 2 Posts

    Default Re: how to draw a widget on another widget?

    here are some cases I can find out:
    1) you can not set the widget as child
    2) you want to get a snap shot

  6. #6
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to draw a widget on another widget?

    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

Similar Threads

  1. Draw Custom widget
    By deepal_de in forum Qt Programming
    Replies: 3
    Last Post: 26th May 2011, 07:27
  2. Draw a line between widget and mouse?
    By AyaKoshigaya in forum Qt Programming
    Replies: 6
    Last Post: 26th April 2010, 06:32
  3. Draw transparent SVG in Background of Widget
    By soul_rebel in forum Qt Programming
    Replies: 0
    Last Post: 28th October 2008, 20:44
  4. Replies: 5
    Last Post: 18th March 2008, 16:11
  5. Draw contents of widget in another widget
    By gustavosbarreto in forum Qt Programming
    Replies: 1
    Last Post: 6th August 2007, 14:43

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.