I'm learning about Qt Model/View with Ruby and I'm trying run the following code
require 'Qt4'
class MyModel < Qt::AbstractListModel
def initialize(data = [])
super()
@data = data
end
def rowCount idx
@data.size
end
def data idx, role = Qt::DisplayRole
if role == Qt::DisplayRole then
Qt::Variant.new @data
else Qt::Variant.new
end
end
end
if $0 == __FILE__
app = Qt::Application.new ARGV
v = Qt::ListView.new
m = MyModel.new(['1', '2', '3'])
v.model = m
v.show
app.exec
end
When I run the script what it shows is a list window with three rows empty. What am I doing wrong? On the other hands, I find it hard to learn to model/view programming with ruby due to the poor documentation (All is C++) anyone know if there are tutorials or something?