USER8
12th October 2013, 07:47
I'm using QDBusConnecton API to detect USB.
The code is:
mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDBusConnection>
#include <QDebug>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
if (!QDBusConnection::systemBus().isConnected()) {
qDebug() << "Cannot connect to system bus";
}
bool connected = QDBusConnection::systemBus().connect(
"org.freedesktop.UDisks",
"/org/freedesktop/UDisks",
"org.freedesktop.UDisks",
"DeviceAdded",
this,SLOT(deviceAdded(QDBusObjectPath)));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::deviceAdded(QDBusObjectPath dev)
{
qDebug() << "device added!"<<dev.path();
}
mainwindow .h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QtGui/QApplication>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow {
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
private slots:
void deviceAdded(QDBusObjectPath dev);
};
#endif // MAINWINDOW_H
I'm getting error as:
mainwindow.cpp:3:27: fatal error: ui_mainwindow.h: No such file or directory
compilation terminated.
Please tell me is there any mistake in this code?
how to solve this Issue?
The code is:
mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDBusConnection>
#include <QDebug>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
if (!QDBusConnection::systemBus().isConnected()) {
qDebug() << "Cannot connect to system bus";
}
bool connected = QDBusConnection::systemBus().connect(
"org.freedesktop.UDisks",
"/org/freedesktop/UDisks",
"org.freedesktop.UDisks",
"DeviceAdded",
this,SLOT(deviceAdded(QDBusObjectPath)));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::deviceAdded(QDBusObjectPath dev)
{
qDebug() << "device added!"<<dev.path();
}
mainwindow .h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QtGui/QApplication>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow {
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
private slots:
void deviceAdded(QDBusObjectPath dev);
};
#endif // MAINWINDOW_H
I'm getting error as:
mainwindow.cpp:3:27: fatal error: ui_mainwindow.h: No such file or directory
compilation terminated.
Please tell me is there any mistake in this code?
how to solve this Issue?