PDA

View Full Version : How to detect Hardware generated signals and reflect on Ui using Qt??



kapoorsudhish
23rd November 2009, 04:39
Hi,
I have to detect some hardware signals like the USB connected, Network availability etc. How can i achieve the above using Qt class refrence...???

nish
23rd November 2009, 11:28
qt wont help you here. you have to use system specific api.

kapoorsudhish
23rd November 2009, 12:56
Thanks for the reply, but can you suggest how the same can be achieved ?? As to how can i approach this problem. What i want is to emit a signal and trap it in my UI application event loop can this be achieved in any ways...???

squidge
23rd November 2009, 17:54
Design a QOBJECT class that detects hardware signals like the USB connected, Network availability etc and emits a signal upon those events. You can then connect those signals to relevent slots in your ui class.

Anything further than that is really outside the scope of this forum.



class HardwareDetector : public QObject
{
Q_OBJECT

public:
HardwareDetector(QObject *parent = 0);

Q_SIGNALS:
USBDetect();
NetworkDetect();
};


then in a relevent function in your .cpp :



emit USBDetect();

kapoorsudhish
24th November 2009, 08:52
The same implementation i have in mind but my problem is to pass the signal from Kernal space to the user space where i can emit Qt signals and take it to the UI. So my concern is to how can i detect the hardware signals using Qt??

wysota
24th November 2009, 08:54
If you're using Linux, you can use HAL through DBUS to interconnect with the hardware.

kapoorsudhish
25th November 2009, 10:45
Yes i am using Linux system, but i dont have any idea of using dbus does qt provide an interface with dbus or how can i achieve the same...????

Thanks in advance.

regards,
sudhish kapoor

wysota
25th November 2009, 12:10
Yes, see the QtDbus module in the docs.