All pastes #758873 Raw Edit

Anonymous

public ruby v1 · immutable
·published 2007-11-02 17:25 UTC
rendered paste body
require "pp"require "Qt4"# require 'bigdecimal'class MyModel < Qt::SortFilterProxyModelattr_reader :model   def initialize(*args)      super(*args)      @model = Qt::StringListModel.new      @model.setStringList((0..10).to_a.collect{|i| "test #{i}"})      setSourceModel(@model)#       @dummy = Hash.new []   end   def data(index, role=Qt::DisplayRole, uff=0)      return Qt::Variant.new unless index.isValid#       item = @dummy[index.column] index.column ##       if uff > 100         super(index, role)      else         data(index, role, uff+1)       end   endendclass MyMainWindow < Qt::MainWindow   slots "test()"   def initialize(*args)      super(*args)      @wid = Qt::Widget.new      @lay = Qt::VBoxLayout.new(@wid)            @model = MyModel.new      table = Qt::TableView.new      table.setModel(@model)      table.setSortingEnabled(true)      btn = Qt::PushButton.new      connect(btn, SIGNAL("clicked()"), self, SLOT("test()"))      @lay.addWidget(table)      @lay.addWidget(btn)      setCentralWidget(@wid)      resize(400,900)   end   def test      GC.start   end   privateend$KCODE='u'Qt.debug_level = Qt::DebugLevel::High if ARGV.shift == "debug"app = Qt::Application.new(ARGV)mainWin = MyMainWindow.newmainWin.showapp.exec