D
David Brunell
I'm trying to load .ui files at runtime using the qui extension and
WidgetFactory rather than pre-translating the .ui XML file to ruby with
rbuic. Here's a simple program:
require 'Qt'
require 'qui'
a = Qt::Application.new(ARGV)
w = QUI::WidgetFactory.create "sampledialog.ui"
w.show()
a.connect(a, SIGNAL('lastWindowClosed()'), a, SLOT('quit()'))
a.exec()
This works just fine in that it dynamically loads and presents the .ui
file as a window. However, how do I connect signals and slots? I
understand the process of method override when doing it the rbuic way,
but this doesn't seem to be working with WidgetFactory. The signals and
slots (but not their handling) are defined in the .ui file. Could
someone give this noob an example of how to implement a slot method? I
tried looking at some C++ examples, but I'm just not making the
connection to ruby. The .ui file is below. It just has two buttons,
Test and Close.
Thanks,
David
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
<class>SampleDialogUI</class>
<widget class="QDialog">
<property name="name">
<cstring>SampleDialogUI</cstring>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>155</width>
<height>45</height>
</rect>
</property>
<property name="caption">
<string>Sample Dialog</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QPushButton" row="1" column="2">
<property name="name">
<cstring>closeButton</cstring>
</property>
<property name="text">
<string>Close</string>
</property>
<property name="toolTip" stdset="0">
<string>Close this dialog</string>
</property>
</widget>
<widget class="QPushButton" row="1" column="1">
<property name="name">
<cstring>testButton</cstring>
</property>
<property name="text">
<string>Test</string>
</property>
<property name="toolTip" stdset="0">
<string>Test command execution</string>
</property>
</widget>
</grid>
</widget>
<connections>
<connection>
<sender>testButton</sender>
<signal>clicked()</signal>
<receiver>SampleDialogUI</receiver>
<slot>testButton_clicked()</slot>
</connection>
<connection>
<sender>closeButton</sender>
<signal>clicked()</signal>
<receiver>SampleDialogUI</receiver>
<slot>closeButton_clicked()</slot>
</connection>
</connections>
<slots>
<slot>testButton_clicked()</slot>
<slot>closeButton_clicked()</slot>
</slots>
<layoutdefaults spacing="6" margin="11"/>
</UI>
WidgetFactory rather than pre-translating the .ui XML file to ruby with
rbuic. Here's a simple program:
require 'Qt'
require 'qui'
a = Qt::Application.new(ARGV)
w = QUI::WidgetFactory.create "sampledialog.ui"
w.show()
a.connect(a, SIGNAL('lastWindowClosed()'), a, SLOT('quit()'))
a.exec()
This works just fine in that it dynamically loads and presents the .ui
file as a window. However, how do I connect signals and slots? I
understand the process of method override when doing it the rbuic way,
but this doesn't seem to be working with WidgetFactory. The signals and
slots (but not their handling) are defined in the .ui file. Could
someone give this noob an example of how to implement a slot method? I
tried looking at some C++ examples, but I'm just not making the
connection to ruby. The .ui file is below. It just has two buttons,
Test and Close.
Thanks,
David
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
<class>SampleDialogUI</class>
<widget class="QDialog">
<property name="name">
<cstring>SampleDialogUI</cstring>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>155</width>
<height>45</height>
</rect>
</property>
<property name="caption">
<string>Sample Dialog</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QPushButton" row="1" column="2">
<property name="name">
<cstring>closeButton</cstring>
</property>
<property name="text">
<string>Close</string>
</property>
<property name="toolTip" stdset="0">
<string>Close this dialog</string>
</property>
</widget>
<widget class="QPushButton" row="1" column="1">
<property name="name">
<cstring>testButton</cstring>
</property>
<property name="text">
<string>Test</string>
</property>
<property name="toolTip" stdset="0">
<string>Test command execution</string>
</property>
</widget>
</grid>
</widget>
<connections>
<connection>
<sender>testButton</sender>
<signal>clicked()</signal>
<receiver>SampleDialogUI</receiver>
<slot>testButton_clicked()</slot>
</connection>
<connection>
<sender>closeButton</sender>
<signal>clicked()</signal>
<receiver>SampleDialogUI</receiver>
<slot>closeButton_clicked()</slot>
</connection>
</connections>
<slots>
<slot>testButton_clicked()</slot>
<slot>closeButton_clicked()</slot>
</slots>
<layoutdefaults spacing="6" margin="11"/>
</UI>