Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt d-bus don't receive signal form udisks
Forum Updated to NodeBB v4.3 + New Features

Qt d-bus don't receive signal form udisks

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 872 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    stima_ua
    wrote on last edited by
    #1

    Hello All,

    I try to handle usb devices changes (remove/add). It's my code:

    /.h/
    @
    #ifndef UDISKS_H
    #define UDISKS_H

    #include <QObject>
    #include <QDBusObjectPath>

    class UDisks : public QObject
    {
    Q_OBJECT

    public:
    UDisks(QObject *parent = 0);

    public slots:
    void device_added(QDBusObjectPath);
    void device_removed(QDBusObjectPath);
    };

    #endif // UDISKS_H
    @

    /.cpp/
    @
    #include "udisks.h"

    #include <QtDBus>
    #include <QDebug>

    const char *udisk_srv = "org.freedesktop.UDisks";
    const char *udisk_path = "/org/freedesktop/UDisks";
    const char *udisk_iface = "org.freedesktop.UDisks";
    const char *udisk_devadd = "DeviceAdded";
    const char *udisk_devrmv = "DeviceRemoved";
    const char *udisk_devsig = "o";

    UDisks::UDisks(QObject *parent) : QObject(parent)
    {
    qDebug() << "added was connected: "
    << QDBusConnection::systemBus().connect(udisk_srv, udisk_path, udisk_iface, udisk_devrmv,
    this, SLOT(device_added(QDBusObjectPath)));

    qDebug() << "removed was connected: "
             << QDBusConnection::systemBus().connect(udisk_srv, udisk_path, udisk_iface, udisk_devrmv,
                                         this, SLOT(device_removed(QDBusObjectPath)));
    

    }

    void UDisks::device_added(QDBusObjectPath)
    {
    qDebug() << "adedd";
    }

    void UDisks::device_removed(QDBusObjectPath)
    {
    qDebug() << "removed";
    }
    @

    /main/
    @
    #include <QCoreApplication>

    #include "udisks.h"

    int main(int argc, char *argv[])
    {
    QCoreApplication a(argc, argv);

    UDisks udisks;
    
    return a.exec&#40;&#41;;
    

    }
    @

    But its not work when I add or remove some USB device.
    Some additional info: Ubuntu 12.04 x64, Qt 5.1.0, gcc x64.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved