QtRuby and use of .ui files

B

Bauduin Raphael

Hi,

Just testing QtRuby right now, so being a real newbie at it....

I'm wondering how I should use .ui files generated with Qtdesigner:
by loading it dynamically like this

w = QUI::WidgetFactory.create "form1.ui"

or by passing it through rbuic and using the ruby code generated?

In the first case, I don't know how to access elements in the ui, for
example a list box in the form, and in the second case the file needs a
transformation step.

Any advice and example welcome.

Thanks

Raph
 
R

Richard Dale

Bauduin said:
Hi,

Just testing QtRuby right now, so being a real newbie at it....

I'm wondering how I should use .ui files generated with Qtdesigner:
by loading it dynamically like this

w = QUI::WidgetFactory.create "form1.ui"

or by passing it through rbuic and using the ruby code generated?

In the first case, I don't know how to access elements in the ui, for
example a list box in the form, and in the second case the file needs a
transformation step.

Any advice and example welcome.
I would use the rbuic tool to generate ruby code. If you use the '-x'
option, rbuic adds a top level stub so you can run it straightaway:

$ rbuic -x form1.ui -o form1.rb
$ ruby form1.rb

The WidgetFactory way is more useful for C++ programs because it means you
can change the UI without having to recompile and link it all. But with
ruby you don't need to do that.

You can pass a 'connector object' Qt::Object instance to
QUI::WidgetFactory.create and it will connect up slots you define in it to
any custom slots inside the ui file. To access a ui element like a list
box, you would need to define a custom slots connected to suitable signals
in the list box.

-- Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top