PDA

View Full Version : Drawing on a widget created via QDesigner



jean
13th January 2009, 19:57
I know how to draw a picture on a QMainWindow via QPainter:

QPainter painter(this).

But, after creating a QFrame (named frame_1) via QDesigner, how to implement the paintEvent in order to make it working with my QFrame ?

In short, I would like to point to my QFrame, not the default (this) QMainWindow.

I have not seen any code from Google or from this forum, since QDesigner is not very used.

By advance, thank you for any help.http://www.qtcentre.org/forum/images/icons/icon3.gif

Jean (a novice, of course).

spirit
13th January 2009, 20:10
you can install event filter for your QFrame object and then handle its QPaintEvent.

jpn
13th January 2009, 20:35
Create a QFrame subclass and promote it in designer.

jean
15th January 2009, 12:08
Thanks for these 2 answers.

My knowledge of C++ processes is still poor (I come from Delphi), but I presume that subclassing would be faster than using an eventFilter. Am I right ?

In fact, I tryed both them, without anay results.:crying:
I red the <promote> URL pointed by JPN, but I understood that promoting is only when you want to customize a widget. The widget is created within QDesigner (an .ui file) but I don't know of to double inherit a QFram object and an object still created with QDesigner.

Could be more explicit ?
Thank you by advance.
Jean.

spirit
15th January 2009, 12:17
read this thread http://www.qtcentre.org/forum/f-newbie-4/t-how-i-could-tell-qpainter-where-is-his-area-of-painting-17232.html/?highlight=QPainter, maybe it will help you.

jean
15th January 2009, 14:15
Thank you !
Now, I have a little bit understand the process. And it works.
Jean.