Qt4 designer, custom slots and rbuic4

C

Chris

Hello everyone,

I just started looking at trying to write some Qt stuff in ruby. I
whipped up a quick widget in designer to see how the whole process
works. When it came time to connect a button to a custom slot I got
stuck. The docs on the internet that deal with designer are all qt3
based. The search button on this forums website is broken, so sorry if
this has been brought up already.

Has anybody had any luck implementing custom slots in ruby without
changing the output of rbuic4? Everything I have tried results in
segfaults and superclass mismatch errors.
 
S

Stefano Crocco

Alle domenica 4 marzo 2007, Chris ha scritto:
Hello everyone,

I just started looking at trying to write some Qt stuff in ruby. I
whipped up a quick widget in designer to see how the whole process
works. When it came time to connect a button to a custom slot I got
stuck. The docs on the internet that deal with designer are all qt3
based. The search button on this forums website is broken, so sorry if
this has been brought up already.

Has anybody had any luck implementing custom slots in ruby without
changing the output of rbuic4? Everything I have tried results in
segfaults and superclass mismatch errors.

I've done this:
* create a custom_widget_base.ui with designer (suppose the form name is
CustomWidgetBase and that it contains a single push button,
named 'push_button')
* run rbuic4 on the file, getting custom_widget_base.rb. This file contains a
class called Ui_CustomWidgetBase, from which a class called CustomWidgetBase,
contained in a module called Ui, is derived.
* create the file custom_widget.rb with the following contents:

require 'custom_widget_base.rb' #require the rbuic4-generated file

class CustomWidget < Qt::Widget

slots 'button_pressed()'

def initialize parent=nil
super #call Qt::Widget constructor
@base=Ui::CustomWidgetBase.new
@base.setupUI self #this is where the widget construction happen
connect @base.push_button,SIGNAL('pressed()'),self,SLOT('button_pressed())
end

def button_pressed
Qt::MessageBox.information self, 'App', 'The button has been pressed'
end

end

As to connecting to custom slots directly from Qt designer, I haven't been
able to find out how to create custom slots in the designer. While in the Qt3
version there was a dialog to do that, it seems to have disappeared in the
new version. Even the examples in the designer manual only show connecting an
existing signal to an existing slot.

I hope this helps.

Stefano
 

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,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top