[Kde-bindings] QtRuby: segfault when using Qt::ForegroundRole

Legolgo legolgo at laposte.net
Mon Jul 26 08:11:48 UTC 2010


Hi everyone,

I started using qtruby a few days ago and so far it's been great.
But I stumbled upon a bug that causes a segfault.

As I just started using Qt and the qtruby binding I don't know if I'm 
doing something wrong with my custom model or if it's a bug of the binding.

Here is some minimal code that reproduce the error:

require "Qt4"

class TaskListModel < Qt::StandardItemModel

     def initialize(parent = nil)
         super(parent)
     end

     def data(index, role)
         if !index.valid?
             return Qt::Variant.new
         end
         if role == Qt::DisplayRole
             item = item(index.row)
             return Qt::Variant.new(item.text)
         end
         #this role cause a segfault, sometimes you have to wait a 
little bit or try to edit rows
         if role == Qt::ForegroundRole
             return Qt::Brush.new()
         end

         return Qt::Variant.new

     end


end

app = Qt::Application.new(ARGV)
@widget = Qt::ListView.new()

@model = TaskListModel.new
@widget.setModel(@model)
#fill model with some data
["toto", "tata", "tutu"].each do |desc|
     item = Qt::StandardItem.new
     item.text = desc
     @model.appendRow(item)
end

@widget.show()
app.exec()

I'm using the libQt4-ruby from ubuntu 10.04 with ruby 1.8



More information about the Kde-bindings mailing list