Hello,
I have just solved a weird problem connecting signals and slots from different namespaces, but I want to be sure I am not complicating matters. I have the following class:
namespace MyLibrary
{
class Data {
};
class Emitter {
signals:
void newData(const Data& d);
};
}
namespace MyLibrary
{
class Data {
};
class Emitter {
signals:
void newData(const Data& d);
};
}
To copy to clipboard, switch view to plain text mode
Then, in MyApplication, I'm trying to connect to the "newData" signal as follows:
namespace MyApplication {
...
connect(emitter, SIGNAL(newData(const MyLibrary::Data&)), this, SLOT(onNewData(const MyLibrary::Data&)));
...
}
namespace MyApplication {
...
connect(emitter, SIGNAL(newData(const MyLibrary::Data&)), this, SLOT(onNewData(const MyLibrary::Data&)));
...
}
To copy to clipboard, switch view to plain text mode
but this does not work. To make it work, I needed to change the Emitter class as follows:
class Emitter {
signals:
void newData(const MyLibrary::Data& d); // added namespace specifier: completely useless as far as C++ is concerned, I believe
};
class Emitter {
signals:
void newData(const MyLibrary::Data& d); // added namespace specifier: completely useless as far as C++ is concerned, I believe
};
To copy to clipboard, switch view to plain text mode
Is this the standard way to fix the problem? Am I missing something?
Thank you
Bookmarks