Last active
August 29, 2015 14:19
-
-
Save hostilefork/61cd8083bb958272caca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Test for http://stackoverflow.com/questions/8455887/stack-object-qt-signal-and-parameter-as-reference/ | |
#include <iostream> | |
#include <QCoreApplication> | |
#include <QTimer> | |
#include "param.h" | |
int main(int argc, char *argv[]) | |
{ | |
QCoreApplication a(argc, argv); | |
qRegisterMetaType<Param>("CopyConstructorParam"); | |
Test t; | |
QTimer::singleShot(200, &t, &Test::run); | |
return a.exec(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Test for http://stackoverflow.com/questions/8455887/stack-object-qt-signal-and-parameter-as-reference/ | |
#ifndef PARAM_H | |
#define PARAM_H | |
#include <iostream> | |
#include <QCoreApplication> | |
#include <QDebug> | |
class Param { | |
public: | |
Param () {} | |
Param (Param const &) { | |
std::cout << "Calling Copy Constructor\n"; | |
} | |
}; | |
class Test : public QObject { | |
Q_OBJECT | |
public: | |
Test () { | |
for (int index = 0; index < 3; index++) { | |
connect( | |
this, &Test::transmit, | |
this, &Test::receive, | |
Qt::QueuedConnection | |
); | |
} | |
} | |
void run() { | |
Param p; | |
std::cout << "transmitting with " << &p << " as parameter\n"; | |
emit transmit(&p); | |
} | |
signals: | |
void transmit(Param * p); | |
public slots: | |
void receive(Param * p) { | |
std::cout << "receive called with " << p << " as parameter\n"; | |
} | |
}; | |
#endif // PARAM_H |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment