On Sunday 26 September 2010, Markus F. wrote:
|
|ruby-1.9.2-p0 > ui.load
|NoMethodError: private method load' called for |#<Qt::UiLoader:0x000000026a81a8 objectName=""> | from (irb):6:in
method_missing’
| from (irb):6
| from /home/mfischer/.rvm/rubies/ruby-1.9.2-p0/bin/irb:17:in `’
You’re calling the load method with the wrong arguments. I think that,
due to
the way the qt bindings work, this ends up calling Kernel#load, which is
a
private method and therefore can’t be called with a receiver. To have
your
code work, you just need to follow the example you posted in your
previous
mail:
require ‘Qt’
require ‘qtuitools’
app = Qt::Application.new []
loader = Qt::UiLoader.new
#Create a file pointing to the .ui file you want to load. Unfortunately,
you
#can’t use a ruby file here
file = Qt::File.new ‘/path/to/ui/file.ui’
#open the file
file.open Qt::File::ReadOnly
#At last, load the ui file. If the widget contained in the ui file
should be
#a child of another widget, pass that widget as secon argument instead
of nil
widget = loader.load file, nil
#Close the file
file.close
#Now do whatever you like with the widget. For example,
widget.show
app.exec
|
|Sometimes skimming through the docs I also find references to korundum
|(e.g. http://rubyforge.org/projects/korundum/ ) which I’ve no clue what
|it is.
|
|Is the rubyforge project related to the qtruby4 gem or is it something
|different?
|
|That’s all really confusing.
Actually, there’s only one qt ruby bindings. The situation is the
following.
The Qt ruby bindings have been born as a part of the ruby bindings for
KDE (in
case you don’t know, KDE is a desktop environment born for Linux and
based on
the Qt libraries). This is “korundum”.
Since KDE is based on Qt, korundum also contains bindings for all of the
Qt
classes, so the developers decided to allow users who don’t have KDE to
install only the parts of korundum containing the bindings to Qt. This
is Qt
ruby (or qtruby).
Originally, the build system of qtruby was the same as the KDE one,
based on
the cmake utility. This wasn’t very easy, expecially on windows (this
also
happened because new releases of qtruby weren’t released very often, so
to
obtain a newer version, you often needed to start from the korundum
sources
and modify the build system to remove anythig related to KDE before
starting
compiling). To make things easier for windows users, a windows binary
gem of
qtruby was created and called qtruby4.
Now, it seems, the korundum developers have decided to create a proper
gem for
qtruby, which is what you’re using. I can’t say much on this, as I
didn’t know
about it until I read your mail
|Stefano: if I may ask, in which environment are you developing?
I’m using the ruby bindings for KDE (that is, korundum) on gentoo linux
|thanks,
|- Markus
I hope this helps
Stefano