QSignalSpy using a QSharedPointer signal?
-
Good day fellow QT coders, hope your code compiles well. I've been reading up on using QTtest and how unit testing works overall. Been a fun last 2 days. I've noticed that QSIgnalSpy doesn't like when I use QSharedPointers to call the signal though.
void UnitTest::checkSignal() { QSharedPointer<ClassBegin> begin; QSignalSpy beginSpy(&begin, &ClassBegin::update); <---- }
I keep getting a C++ a nonstatic member reference must be relative to a specific object error at the <---- line above. I didn't see it anywhere in the docs but can QSignalSPy use QSharedPointers?
Appreciate the help, thank you!
-
Hi,
You need to connect it to the object that is hold by the shared pointer not by the pointer.
-
No
connect(begin.data(), ...)
But you can only do this once you put something in the QSharedPointer so you might as well do a normal connect call when you set the object in "begin".
You cannot "preemptlively" connect.