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.
on 2007-03-04 16:54
on 2007-03-04 17:18
Alle domenica 4 marzo 2007, Chris ha scritto: > 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
on 2007-03-04 19:19
> I hope this helps. > > Stefano Yes it did. Thank you Stefano, everything is working now. Chris