Friday, April 3, 2009

Another usage of UI File from QtRuby #1

In recent post, I mentioned of Qt Designer's XML file (aka UI file). This post explains how to use command rbuic4. But, another way to use UI file exists. It's QUiLoader. In QtRuby examples of KDE TechBase, samples are written with below caution:

This section needs improvements: Please help us to
cleanup confusing sections and
fix sections which contain a todo

Remove example that does not work

Really? So let's try with defaults.ui, that is corresponding UI file in recent post.
require 'Qt4'
require 'qtuitools'

UI_FILES_PATH = "/opt/qtsdk-2009.01/qt/examples/widgets/stylesheet/layouts"

Qt::Application.new(ARGV) do
file = Qt::File.new("#{UI_FILES_PATH}/default.ui")
file.open(Qt::File::ReadOnly)
window = Qt::UiLoader.new.load(file, nil)
file.close
window.show
exec
end

This code block is saved as file named "ui_loader_example.rb". Then execute this.
>/opt/ruby-1.9.1/bin/ruby ui_loader_example.rb
ui_loader_example.rb:2:in `require': no such file to load -- qtuitools (LoadError)
from ui_loader_example.rb:2:in `<main>'

It fails, but unexpected way. to be continued...

No comments:

Post a Comment