将QtRuby与DBus信号结合使用
我有一个用Ruby编写的QtGUI脚本,我想在检测到新的USB设备时从DBus获取信号。如果我在没有任何参数的情况下连接到插槽到DBUS信号,则脚本可以工作,但这不会给我插入设备的任何信息。但是,使用QDBusObjectPath作为插槽的参数(这在C++中非常有效),我遇到了某种绑定错误“ruby-1.9.3-p0/gems/qtbindings-4.6.3.4/lib/Qt/qtruby4.rb:469:in`Qt_metacall':当Qt试图调用我的插槽时,无法将'QDBusObjectPath&'作为插槽参数(ArgumentError)”处理 这里熟悉Qt-Ruby绑定内部工作的人知道可以给我一些关于插入系统的USB设备的信息吗?提前谢谢 以下是我的代码:将QtRuby与DBus信号结合使用,ruby,qt,dbus,Ruby,Qt,Dbus,我有一个用Ruby编写的QtGUI脚本,我想在检测到新的USB设备时从DBus获取信号。如果我在没有任何参数的情况下连接到插槽到DBUS信号,则脚本可以工作,但这不会给我插入设备的任何信息。但是,使用QDBusObjectPath作为插槽的参数(这在C++中非常有效),我遇到了某种绑定错误“ruby-1.9.3-p0/gems/qtbindings-4.6.3.4/lib/Qt/qtruby4.rb:469:in`Qt_metacall':当Qt试图调用我的插槽时,无法将'QDBusObject
require 'Qt'
class MyDisk < Qt::Object
slots 'on_device_added_ext(QDBusObjectPath)',
'on_device_removed_ext(QDBusObjectPath)'
def initialize
super
end
def on_device_added_ext message
puts "Deviced Added with path = #{message.path()}"
end
def on_device_removed_ext message
puts "Deviced Removed with path = #{message.path()}"
end
end
app = Qt::Application.new ARGV
test = MyDisk.new
ret = Qt::DBusConnection::systemBus().connect(
"org.freedesktop.UDisks",
"/org/freedesktop/UDisks",
"org.freedesktop.UDisks",
"DeviceAdded",
test, SLOT('on_device_added_ext(QDBusObjectPath)'))
ret = Qt::DBusConnection::systemBus().connect(
"org.freedesktop.UDisks",
"/org/freedesktop/UDisks",
"org.freedesktop.UDisks",
"DeviceRemoved",
test, SLOT('on_device_removed_ext(QDBusObjectPath)'))
app.exec
require'Qt'
类MyDisk