QGraphicsItem Resize Problem
Hi,
I am using the DiagramScene example of Qt example for my application, where we have a mainwindow with tool box and QGraphicsView, in toolbox we have some shapes which r drawn using a DiagramItem class which inherits QGraphicsPolygonItem.
My problem is I want to give the Item the resize functionality where if the user click on item the user must be given the 6points on the rectangle to drag and resize the Item.
Where should i implement this functionality in DiagramScene class or DiagramItem class. in DiagramItem Class there is no paint() to repaint the Item.
What are the methods to implement.
could any one help to achieve this functionality.
thank u in advance.
Re: QGraphicsItem Resize Problem
the paint functionality is there for graphicsitem ...
reimplement
QGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget
http://doc.trolltech.com/4.5/qgraphicsitem.html#paint
and update() also available ..
Re: QGraphicsItem Resize Problem
I am New to Qt plz help me with some more Ideas
Re: QGraphicsItem Resize Problem
widgets paint itself using this protected function
QWidget::paintEvent();
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 ..
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::paint() .. inside with the set flag redraw your six points ...