我的QServiceManager有问题。
myfile.ps1
我可以在条形接口IFoo上指定函数调用,如:
QServiceManager manager;
CFoo bar;
QList<QServiceInterfaceDescriptor> ServiceList = manager.findInterfaces(SERVICE_NAME);
for(int i = 0; i < ServiceList.length(); i++)
{
bool accessGranted = false;
QServiceInterfaceDescriptor descriptor = ServiceList[i];
if (descriptor.interfaceName() == INTERFACE)
{
bar = manager.loadLocalTypedInterface<IFoo>(descriptor, accessGranted);
if (NULL == bar && false == accessGranted)
{
connect(bar, SIGNAL(signal()),
this, SLOT(slot()));
}
}
}
我看到远程对象foo正在接收函数调用,但是当我远程发送信号时:
bar.function()
没有收到。永远不会调用函数slot()。我检查了connect函数被调用并返回TRUE。谁能查明我做错了什么?
答案 0 :(得分:1)
如果您的班级不是qobject,则不能使用信号和插槽
#include<QObject>
class CFoo : public QObject, public IFoo
{
Q_OBJECT
signals:
void signal();
public:
void function()
{
emit signal();
}
};