使用QtRuby和DBus信号

时间:2012-02-29 15:33:49

标签: ruby qt dbus

我有一个用Ruby编写的Qt GUI脚本,我希望在检测到新的USB设备时从DBus获取信号。如果我连接到我的插槽到DBUS信号没有任何参数,脚本工作,但这不会给我任何关于插入的设备的信息。但是,使用QDBusObjectPath作为我的插槽的参数(这与C ++完美配合)我遇到了某种绑定错误“ruby-1.9.3-p0 / gems / qtbindings-4.6.3.4 / lib / Qt / qtruby4.rb: 469:在`qt_metacall'中:无法处理'QDBusObjectPath&'作为插槽参数(ArgumentError)“当Qt试图调用我的插槽时。

这里有人熟悉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

0 个答案:

没有答案