class DragLabel

Public Class Methods

new(text, parent = nil) click to toggle source
Calls superclass method
# File examples/draganddrop/draggabletext/draglabel.rb, line 28
def initialize(text, parent = nil)
    super(text, parent)
    setFrameShape(Qt::Frame::Panel)
    setFrameShadow(Qt::Frame::Raised)
end

Public Instance Methods

mousePressEvent(event) click to toggle source
# File examples/draganddrop/draggabletext/draglabel.rb, line 34
def mousePressEvent(event)
    plainText = text(); # for quoting purposes

    mimeData = Qt::MimeData.new
    mimeData.text = plainText

    drag = Qt::Drag.new(self)
    drag.mimeData = mimeData
    drag.hotSpot = event.pos - rect.topLeft

    dropAction = drag.start(Qt::CopyAction | Qt::MoveAction)
    
    if dropAction == Qt::MoveAction
        close()
        update()
    end
end