[Kde-bindings] Qtruby: Can't initialize obejct < Qt::Object
Han Holl
han.holl at pobox.com
Tue Jan 17 20:46:10 UTC 2006
Hello,
It _almost_ works, but not quite. I want an action performed at a regular
interval, and from browsing this mailing list I thought I had best use
Qt::Timer for that.
I do not however succeed in initializing the object that has to do the work
properly:
#!/usr/bin/ruby
require 'Qt'
class BackGround < Qt::Object
slots 'show()'
def initialize(parent, files)
# Qt::debug_level = Qt::DebugLevel::High
@files = files
STDERR.puts @files.class
super(parent)
end
def show
STDERR.puts @files.nil?
end
end
a = Qt::Application.new(ARGV)
w = Qt::Widget.new
b = BackGround.new(w, Hash.new)
timer = Qt::Timer.new(b)
Qt::Object.connect(timer, SIGNAL('timeout()'), b, SLOT('show()'))
timer.start(2000)
a.setMainWidget(w)
w.show
a.exec
### end-of-code
This produces:
Hash
true
true
... (every two seconds).
So @files becomes nil after my attempt to initialize the Qt::Object parent,
and I have to have that for the SIGNAL/SLOT mechanism to work.
Also I'm not to certain about who should be parent to who. The Background
class has nothing to do with Qt, except of course for the slot.
Hints would be very welcome.
Cheers,
Han Holl
(I'm trying to construct a little program that displays photos on the root
window, fetches the caption from the EXIF header and displays it, and that
has controls to pause, go back, change duration and so on. Learned a lot so
far).
More information about the Kde-bindings
mailing list