[英]USB detection using qt application
I'm beginner to Qt.I thought to use QDbusConnection API to get information about device connected. 我是Qt的初学者,我想使用QDbusConnection API来获取有关所连接设备的信息。 I used following code
我用下面的代码
#include <QtCore/QDebug>
#include <QtGui/QApplication>
#include <QtDBus/QDBusConnection>
#define HAL_SERV "org.freedesktop.Hal"
#define HAL_MGR_INT "org.freedesktop.Hal.Manager"
#define HAL_DEV_INT "org.freedesktop.Hal.Device"
#define HAL_MGR_PATH "/org/freedesktop/Hal/Manager"
#define HAL_DEVS_PATH "/org/freedesktop/Hal/devices"
class Hal : public QObject
{
Q_OBJECT
public:
Hal() :
QObject(),
cnx( QDBusConnection::connectToBus( QDBusConnection::SystemBus, "system" ) )
{
cnx.connect(
HAL_SERV, HAL_MGR_PATH, HAL_MGR_INT, "DeviceAdded",
this, SLOT(added(QString)) );
cnx.connect(
HAL_SERV, HAL_MGR_PATH, HAL_MGR_INT, "DeviceRemoved",
this, SLOT(removed(QString)) );
}
private slots:
void added( QString dev )
{
qDebug() << __FUNCTION__ << dev;
}
void removed( QString dev )
{
qDebug() << __FUNCTION__ << dev;
}
private:
QDBusConnection cnx;
};
int main( int ac, char * * av )
{
QApplication app( ac, av );
Hal hal;
return( app.exec() );
}
#include "main.moc"
I build the project successfully,If I run I'm not observing any output. 我成功构建了项目,如果运行,我将不会观察到任何输出。 and Debugger showing warning like below : GDB: Failed to set controlling terminal: Inappropriate ioctl for device\\n"
和调试器显示如下警告:GDB:无法设置控制终端:设备的ioctl不适当\\ n“
What is the problem ,can anyone explain me in detail. 有什么问题,谁能详细解释一下。 how to run the application?should I need to any arguments?
如何运行该应用程序?我需要任何参数吗?
Regards, Sujatha 问候,Sujatha
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.