Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将QtRuby与DBus信号结合使用_Ruby_Qt_Dbus - Fatal编程技术网

将QtRuby与DBus信号结合使用

将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

我有一个用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设备的信息吗?提前谢谢

以下是我的代码:

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