Da ne pozabim!!!
> 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:
- Ustvari custom_widget_base.ui z Designerjem (predpostavimo, da se forma imenuje CustomWidgetBase in da vsebuje en sam push button z imenom 'push_button')
- Zaženi rbuic4 na datoteko, da dobiš custom_widget_base.rb. Ta file vsebuje razred z imenom Ui_CustomWidgetBase, iz katerega je izpeljan razred CustomWidgetBase, ki ga vsebuje modul Ui.
- Ustvari datoteko custom_widget.rb z naslednjo vsebino:
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