×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    1

    how to paint on child widgets in qt4.5

    I written a code in QT(4.5) to draw or paint a circle on parent widget.
    The code is like this.

    void frmdemo:aintEvent (QPaintEvent *)
    {

    QPainter paint(this);

    paint.setPen(red);
    paint.setBrush(Qt::green);
    paint.drawEllipse(10, 400, 25, 25);

    }

    The above code will paint a circle on parent widget.

    But if i want to draw a circle on tabwidget, ie on child widget because tabwidget is lies on parent widget. The code is like this.

    void frmdemo:aintEvent (QPaintEvent *)
    {

    QPainter paint(tabplot);

    paint.setPen(red);
    paint.setBrush(Qt::green);
    paint.drawEllipse(10, 400, 25, 25);

    }

    The above code will not paint a circle on tabwidget named as tabplot. This code will work in qt3.1, but not in qt4.5.
    After executing the pgm, the message will come in terminal window as widget painting only begin as a paintevent.

    how to paint a circle on child widget. please suggest me.

  2. #2
    Super Contributor
    Join Date
    Jul 2008
    Posts
    2,020

    Re: how to paint on child widgets in qt4.5

    Know this eeker too well. You can only paint in a widget in its OWN paint event. So you need to call the repaint() of the widget, override the widget's repaint and to the work there.

    New in Qt 4; I don't like it - but it has to be due to compatibility.
    The lines above are the best I have to offer.If anyone of you is of more advanced knowledge, I ask for your patience and understanding! - unknown arab poet
    http://www.tamoggemon.com - Symbian blog - Windows Phone blog
    My other blogs:
    webOS blog iPhone blog BlackBerry blog Samsung bada blog Android blog

  3. #3
    Regular Contributor
    Join Date
    Mar 2009
    Posts
    430

    Re: how to paint on child widgets in qt4.5

    What is the usecase of doing such things? I guess it will not work in other toolkits too. So I think there will be a clean solution in solving your problem when knowing the bigger picture.

  4. #4
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: how to paint on child widgets in qt4.5

    Why don't you just create a new widget, position it over the child, and paint on that?

Similar Threads

  1. Child Thread call failed
    By kunlamp in forum Symbian
    Replies: 0
    Last Post: 2009-11-10, 06:46
  2. s60 widgets development
    By ambatisreedhar in forum Symbian
    Replies: 3
    Last Post: 2009-09-25, 14:41
  3. Thinlet widgets with paint method
    By KevinBoyd in forum Mobile Java General
    Replies: 0
    Last Post: 2009-09-05, 21:19
  4. Replies: 4
    Last Post: 2009-02-17, 05:47
  5. Announcing the Winners of the WidSets widgets coding contest
    By Maveric in forum Widsets Development
    Replies: 0
    Last Post: 2008-07-04, 10:05

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×