Class: RobotPart
- Inherits:
-
Qt::GraphicsItem
- Object
- Qt::Base
- Qt::GraphicsItem
- RobotPart
- Defined in:
- ext/ruby/qtruby/examples/graphicsview/dragdroprobot/robot.rb
Overview
** ** Copyright © 2004-2005 Trolltech AS. All rights reserved. ** ** This file is part of the example classes of the Qt Toolkit. ** ** This file may be used under the terms of the GNU General Public ** License version 2.0 as published by the Free Software Foundation ** and appearing in the file LICENSE.GPL included in the packaging of ** this file. Please review the following information to ensure GNU ** General Public Licensing requirements will be met: ** www.trolltech.com/products/qt/opensource.html ** ** If you are unsure which license is appropriate for your use, please ** review the following information: ** www.trolltech.com/products/qt/licensing.html or contact the ** sales department at [email protected]. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. **
** Translated to QtRuby by Richard Dale
Direct Known Subclasses
Instance Method Summary collapse
- #dragEnterEvent(event) ⇒ Object
- #dragLeaveEvent(event) ⇒ Object
- #dropEvent(event) ⇒ Object
-
#initialize(parent) ⇒ RobotPart
constructor
A new instance of RobotPart.
Methods inherited from Qt::GraphicsItem
Methods inherited from Qt::Base
#%, #&, #*, #**, #+, #-, #-@, #/, #<, #<<, #<=, #==, #>, #>=, #>>, #QCOMPARE, #QEXPECT_FAIL, #QFAIL, #QSKIP, #QTEST, #QVERIFY, #QVERIFY2, #QWARN, #^, ancestors, #is_a?, #methods, private_slots, #protected_methods, #public_methods, q_classinfo, q_signal, q_slot, signals, #singleton_methods, slots, #|, #~
Constructor Details
#initialize(parent) ⇒ RobotPart
Returns a new instance of RobotPart.
28 29 30 31 32 33 34 |
# File 'ext/ruby/qtruby/examples/graphicsview/dragdroprobot/robot.rb', line 28 def initialize(parent) super(parent) @color = Qt::Color.new(Qt::lightGray) @pixmap = Qt::Pixmap.new @dragOver = false setAcceptDrops(true) end |
Instance Method Details
#dragEnterEvent(event) ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'ext/ruby/qtruby/examples/graphicsview/dragdroprobot/robot.rb', line 36 def dragEnterEvent(event) if event.mimeData.hasColor || self.kind_of?(RobotHead) && event.mimeData.hasImage event.accepted = true @dragOver = true update() else event.accepted = false end end |
#dragLeaveEvent(event) ⇒ Object
47 48 49 50 |
# File 'ext/ruby/qtruby/examples/graphicsview/dragdroprobot/robot.rb', line 47 def dragLeaveEvent(event) @dragOver = false update() end |
#dropEvent(event) ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'ext/ruby/qtruby/examples/graphicsview/dragdroprobot/robot.rb', line 52 def dropEvent(event) @dragOver = false if event.mimeData.hasColor @color = qVariantValue(Qt::Color, event.mimeData.colorData) elsif event.mimeData.hasImage @pixmap = qVariantValue(Qt::Pixmap, event.mimeData.imageData) end update() end |