Hi,
I want to draw line without writing code in paintEvent() function. I don't want to declare
or define the PaintEvent() function. I want to write my own function.
Thanks and Regards
Hi,
I want to draw line without writing code in paintEvent() function. I don't want to declare
or define the PaintEvent() function. I want to write my own function.
Thanks and Regards
Let's see what the documentation says:
So, if you want to paint directly on the widget, you need to implement the paint event. You can call your own functions from within the paint event.Warning: When the paintdevice is a widget, QPainter can only be used inside a paintEvent() function or in a function called by paintEvent(); that is unless the Qt::WA_PaintOutsidePaintEvent widget attribute is set. On Mac OS X and Windows, you can only paint in a paintEvent() function regardless of this attribute's setting.
But, you can also paint on a pixmap or picture, then you don't need the paint event. But you need a widget that displays the picture (a QLabel for example).
On other option is also to install an event filter, catch the paint event and then draw there.
What do you like to draw exactly? Do you like to draw a line on an existing widget?
Then you have to re-implement the paintEvent()-Method in a subclass of the widget. You can call Subclass:aintEvent(event); to draw the widget and then use QPainter to draw extra stuff on it...
It is possible to write your own paint()-Funktion but you have to call it from the paintEvent()-Method, otherwise it will not work out.
Well... go ahead.. write your own function..
in your function.. draw the line onto a pixmap.. and then set this pixmap on a label..
but that wud be inefficient,, dont you think so ?
Bookmarks