0
我想連接到BlueDevil::Manager::devicesChanged
,但是當我運行我的程序時出現錯誤Object::connect: No such slot Handler::changed(QList<Device*>) in src/handler.cpp:26
我該如何解決這個錯誤?據我所知,改變了正確的類型。qt和libbluedevil:沒有這樣的插槽
main.cpp中:
#include <QApplication>
#include "handler.h"
int main(int argc, char **argv)
{
QApplication app(argc, argv);
Handler handler;
return app.exec();
}
handler.h中:
#include <bluedevil/bluedevil.h>
#include <iostream>
#include <QObject>
class Handler : public QObject
{
Q_OBJECT
public:
Handler();
public Q_SLOTS:
void changed(const QList<BlueDevil::Device*> &devices);
private:
BlueDevil::Manager *manager;
BlueDevil::Adapter *defaultAdapter;
};
handler.cpp
#include <bluedevil/bluedevil.h>
#include <iostream>
#include <QObject>
#include "handler.h"
using namespace BlueDevil;
void Handler::changed(const QList<Device*> &devices)
{
Q_FOREACH (const Device *device, devices)
{
std::cout << qPrintable(device->friendlyName()) << std::endl;
}
}
Handler::Handler() : QObject()
{
manager = Manager::self();
defaultAdapter = manager->defaultAdapter();
connect(defaultAdapter, SIGNAL(devicesChanged(QList<Device*>)),
this, SLOT(changed(QList<Device*>)));
}
如果我將其更改爲'BlueDevil :: Device',我在src/handler.cpp中得到'Object :: connect:No such signal BlueDevil :: Adapter :: devicesChanged(QList): 23' –
brennie
2012-01-01 20:00:13
增加第二個選項,可以工作取決於BlueDevil文件的處理方式。 – Mat 2012-01-01 20:15:21
'QObject :: connect:不兼容的發送者/接收者參數 BlueDevil :: Adapter :: devicesChanged(QList) - > Handler :: changed(QList )' –
brennie
2012-01-01 20:39:35