Closed Maziar123 closed 2 years ago
I'd recommend starting by checking the tutorial, it explains the library thoroughly: https://github.com/woboq/verdigris/blob/master/tutorial/tutorial.cpp
Hi
I Read it have do in W_SLOT But same way in W_SIGNAL NOT work :
void do_message(const QString& name) {
qDebug("hello %s", qPrintable(name)); }
W_SIGNAL(do_message)
error: expected unqualified-id before ‘{’ token
70 | W_SIGNAL(do_message)
| ^~~~
There's a misunderstanding it seems: in Qt signals aren't supposed to have an user-given implementation.
See for instance the official Qt documentation: https://doc.qt.io/qt-5/signalsandslots.html ; notice how the signals aren't given any implementation (in "normal" Qt, it's moc which does that).
the code that will work is :
void do_message(const QString& name)
W_SIGNAL(do_message)
If you want to call something in do_message
then you have to connect the signal to a slot somewhere:
connect(my_obj, &Foo::do_message,
[] (const QString& name) { qDebug("hello %s", qPrintable(name)); });
HI
thanx for lambda solution
i think this good for add to tutorial.cpp
It is already done here :)
https://github.com/woboq/verdigris/blob/master/tutorial/tutorial.cpp#L71
Hi when i use in class implementation such as below sample how use W_SIGNAL for do_message ?
class foo { ... ... void a(...){ //some imp. }
void do_message() { //some imp... }
};