Results 1 to 7 of 7

Thread: Hot plug and button event

  1. #1
    Join Date
    Jan 2009
    Posts
    14
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Exclamation Hot plug and button event

    Hello guys!

    I need to refresh the my form whenever the usb device inserted or removed.... I have little knowledge about the hotplug. I dont know how to connect the hotplug event to my button event. Simply i can say,i want to invoke the button event when ever hotplug script run.... Can anybody help???


    Advance thanks...
    Last edited by kpmsivachand; 26th January 2009 at 14:00.

  2. #2
    Join Date
    Jul 2008
    Posts
    139
    Thanks
    9
    Thanked 18 Times in 15 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Hot plug and button event

    Hi,
    Actually I am going through the same thing right now. I am using QtEmbedded 4.4.1 with Linux and I cannot find any solution for doing this. It seems QtExtended has a QBaseModule made for these kind of things.
    I did it kind of awkwardly but it works. It my hotplug mounting script when the usb device gets mounted I create a file in /var/run/usb/ with the usb type info. Then in my remove script I delete that file. In my Qt Application I have a thread in my usb window that checks if that file exists QFile.exists(). I then signal my window if connected or not. If you find an easier method let me know.
    Thanks.

  3. #3
    Join Date
    Jul 2008
    Posts
    139
    Thanks
    9
    Thanked 18 Times in 15 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Hot plug and button event

    Hi,
    I think D-Bus is another blackhole I don't have time for right now, I'll consider this on my next version. (recompile qt, libraries, etc).
    Here is the response I received from Qt Tech support:
    For Qt Embedded or Qt/Linux:
    - If you want to know when a USB stick has been plugged in and then read data from it, this should be relatively easy. When the USB stick is plugged, most morden Linux kernels will automatically mount it to a particular location that would let you access it using the normal file system operation. If the Linux kernel is compiled with HAL support (Hardware Abstraction Layer) and D-Bus is installed then you can use the 'hald' daemon to receive notifications. When any device is plugged in, you can use the QtDBus? module to listen on the system bus and be notifed of new devices:
    Qt Code:
    1. if (!QDBusConnection::systemBus().isConnected()) {
    2. qDebug() << "Cannot connect to system bus";
    3. }
    4.  
    5. bool connected = QDBusConnection::systemBus().connect(
    6. "org.freedesktop.Hal",
    7. "/org/freedesktop/Hal/Manager",
    8. "org.freedesktop.Hal.Manager",
    9. "DeviceAdded",
    10. this, SLOT(deviceAdded()));
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2009
    Posts
    14
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Cool Re: Hot plug and button event

    Thanks QbelcorT!

    thanks for the code let me try out now......

  5. #5
    Join Date
    May 2009
    Posts
    55
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Hot plug and button event

    Hi,

    I try to use this code snippet for test if usb device is connected but I get error during Dbus connection : connect: Resource temporarily unavailable.

    I'm using opensuse 11.

    Thanks

  6. #6
    Join Date
    May 2009
    Posts
    55
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Hot plug and button event

    Sorry my fault everything works fine now.

  7. #7
    Join Date
    Jul 2013
    Posts
    5
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Hot plug and button event

    Hi QbelcorT & kpmsivachand,

    I am also working on same thing hotplug to the qt application.How can I confirm my Ubuntu-11.10(Kernel-3.0) compiled with HAL.

    I have posted my Qt application hot plug problem in one of the Qt fourm. Can you please read following link to understand my question .

    http://www.qtcentre.org/threads/5541...675#post247675

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.