widgets paint itself using this protected function
QWidget:
aintEvent();
so if u want to change the actual structure of the widget or with the widget u want to create new widget with different size and structure we need to reimplement the void paintEvent() virtual function ... u can see lots of Qt examples using this ...
http://doc.trolltech.com/4.5/qpaintevent.html
paintEvent() occurs:
paintEvent() method is automatically called when:
* your widget is shown for first time .
* after a window has been moved to reveal some part (or all ) the widget .
* the window in which the widget lies is restored after being minimzed
and more important ..
when u call update()
update():
it will remove the currently available paint and start painting with the paintEvent() function ..
places a paintevent into the event queue, no painting occurs untill current metod exits, and control returns to event handler ,,
paintEvent() <- QWidget ,,, like wise
paint( Painter *painter, const QStyleOptionGraphicsItem *, QWidget * ) <- QGraphicsItem
if we need to re draw the item , set color , add line, text, rectangle inside the item reimplement these two functions ..
void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *);
QRectF boundingRect() const;
To copy to clipboard, switch view to plain text mode
in your case .. if the user clicks the item .. in item class set some flag and call update() to repaint .. update() will call your QGraphicsItem:
aint() .. inside with the set flag redraw your six points ...
Bookmarks