我正在尝试以这种方式连接到信号:
QObject::connect(myObj, SIGNAL(mySignal(std::list<MyClass*> myList)), this, SLOT(mySlot(std::list<MyClass*> myList)));
插槽未被调用。那是错的吗?我可以std::list
成对signal/slot
使用吗?
编辑:没有参数的同一对工作
class TestThread : public QThread
{
Q_OBJECT
public:
.....
protected:
virtual void run();
private:
std::list<MyClass*> myList;
signals:
void mySignal(std::list<MyClass*>&);
};
Q_DECLARE_METATYPE (std::list<MyClass*>)
编辑:
void mySlot(const std::list<MyClass*> &);
void
MyManager::mySlot(const std::list<MyClass*> &theList)
{
std::cout << "mySlot " << std::endl;
}
void mySignal(const std::list<MyClass*> &theList);
TestThread ::TestThread (std::list<MyClass*>&theList, QObject *parent)
: QThread(parent), myList(theList)
{
}
void
TestThread ::run()
{
...
emit mySignal(myList);
}
到底:
QObject::connect(threadObj, SIGNAL(mySignal(std::list<MyClass*>)), this, SLOT(mySlot(std::list<MyClass*>)));