class SpinBoxDelegate

Public Class Methods

new(parent = nil) click to toggle source

A delegate that allows the user to change integer values from the model using a spin box widget.

Calls superclass method
# File examples/itemviews/spinboxdelegate/spinboxdelegate.rb, line 31
def initialize(parent = nil)
    super(parent)
end

Public Instance Methods

createEditor(parent, option, index) click to toggle source
# File examples/itemviews/spinboxdelegate/spinboxdelegate.rb, line 35
def createEditor(parent, option, index)
    editor = Qt::SpinBox.new(parent)
    editor.minimum = 0
    editor.maximum = 100
    editor.installEventFilter(self)

    return editor
end
setEditorData(editor, index) click to toggle source
# File examples/itemviews/spinboxdelegate/spinboxdelegate.rb, line 44
def setEditorData(editor, index)
    value = index.model().data(index, Qt::DisplayRole).to_i

    @spinBox = editor
    @spinBox.value = value
end
setModelData(editor, model, index) click to toggle source
# File examples/itemviews/spinboxdelegate/spinboxdelegate.rb, line 51
def setModelData(editor, model, index)
    @spinBox = editor
    @spinBox.interpretText
    value = @spinBox.value

    model.setData(index, Qt::Variant.new(value))
end
updateEditorGeometry(editor, option, index) click to toggle source
# File examples/itemviews/spinboxdelegate/spinboxdelegate.rb, line 59
def updateEditorGeometry(editor, option, index)
    editor.geometry = option.rect
end