Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Showcase
  4. QDeviceWatcher-Make hotplug detection easy
Forum Updated to NodeBB v4.3 + New Features

QDeviceWatcher-Make hotplug detection easy

Scheduled Pinned Locked Moved Showcase
3 Posts 2 Posters 16.8k 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.
  • I Offline
    I Offline
    ibingow
    wrote on last edited by
    #1

    It's my project: https://github.com/wang-bin/qdevicewatcher
    Just need QtCore module.
    It works fine on linux and windows. I have tested on my ubuntu and win7. Usually you just need the signals @deviceAdded(const QString& device)@ and @deviceRemoved(const QString& device)@ in QDeviceWatcher.

    To detect the device changes, i use netlink in linux(kernel 2.6) and internel window in windows.
    In windows, I tried two method,
    @virtual bool QCoreApplication::winEventFilter(MSG* msg, long* result)
    //and
    virtual bool QWidget::winEvent(MSG* msg, long* result)@
    I hope my class is just a subclass of QObject, and do not use GUI module, so I started to find other ways. At last I refer to qdrive project: https://gitorious.org/qdrive/qdrive
    In qdrive project, it watch /etc/mtab in linux, but some systems will not mount new disk, so I use netlink.
    This class is only for watching hotplug events now. You can deal with the device yourself, e.g. mount and umount the device.
    !http://qt-apps.org/CONTENT/content-pre1/145200-1.png(windows)!
    !http://qt-apps.org/CONTENT/content-pre2/145200-2.png(ubuntu)!
    EDIT: moved to showcase, Gerolf

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      Your second link is broken. It should not include the dot at the end.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • I Offline
        I Offline
        ibingow
        wrote on last edited by
        #3

        [quote author="koahnig" date="1315736864"]Your second link is broken. It should not include the dot at the end. [/quote]

        I see. What a stupid mistake.

        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