views:

36

answers:

1

So I've been trying to make ruby read my Qt4 design and it's not working, at all. I've created a design in Qt4 Designer and saved it as a .ui file. Then I used rbuic4 to convert it to a design_ui.rb and Qt4. My current ruby main file looks like this:

require 'gui/design_ui.rb'
require 'Qt4'

class AppMain < Ui_MainWindow
 def initialize(app)
  @app = app
 end
end

# create and show dialog
if $0 == __FILE__
   app = Qt::Application.new(ARGV)
   dialog = AppMain.new(app)
   dialog.show
   app.exec
end

I Seriously can't find a decent guide to properly using ruby and Qt4 Designer. They all do different stuff and none of them works. Please help a newbie out here?

A: 

Something like this:

class AppMain < Qt::MainWindow
    def initialize(parent = nil)
        super
        @ui = Ui_Main_window.new
        @ui.setupUi self
    end
end

Then

application = Qt::Application.new(ARGV)
main_window = AppMain.new
main_window.show
application.exec
Anonymous scholar