[Qt-interest] How can I draw some hint line on widget when I am dragging a widget on it?
Oliver.Knoll at comit.ch
Oliver.Knoll at comit.ch
Thu Jul 16 15:00:55 CEST 2009
Kermit Mei wrote on Thursday, July 16, 2009 3:10 PM:
> I want to drag some buttons on a widget. And I divided the widget
> into some equivalent areas. The buttons are in the areas. Now I want
> to draw the areas when the button is dragging. How can I do it?
So for your widget which is supposed to draw the hinting lines:
- In the dragEnter Event (http://doc.qtsoftware.com/4.5/qwidget.html#dragEnterEvent), identify the object, and if you accept it (when it is "droppable"), set a flag 'drawHintingLines', indicating that the helper lines are now to be drawn
- call this->update() (triggers a re-draw of this widget)
- in your paintEvent() method, evaluate the 'drawHintingLines'; if it is set to TRUE, draw them (with the rest of the widget); otherwise, don't draw them (just draw the usual stuff)
- in the dragLeaveEvent, set the 'drawHintingLines' to FALSE; call this->update() (triggers a re-draw of this widget)
- in the dropEvent, also reset the 'drawHintingLines'; call this->update() (so the helper lines disappear again due to the triggered re-painting)
Something along the above lines should do it.
Cheers, Oliver
--
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22
More information about the Qt-interest-old
mailing list