bad syntax on connect() statement
Solved
General and Desktop
-
Hi all - my notes are at home and I've started a new job (where I'm trying to make a case for adopting Qt). I'm trying to put together a very small example, but getting an error.
Here's the code:
#include "widget.h" #include "serial.h" #include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); Widget w; Serial s; QObject::connect(s, &Serial::newText, w, &Widget::addText); w.show(); return a.exec(); }
And here's the error:
C:\Users\mzimmers.CYBERDATA\Qt projects\WiFiButtonProvisioner\main.cpp:12: error: no matching function for call to 'QObject::connect(Serial&, void (Serial::*)(QString), Widget&, void (Widget::*)(QString))' QObject::connect(s, &Serial::newText, w, &Widget::addText); ^
I'm sure I'm botching the syntax, but I can't find my error. Can someone lend a hand? Thanks.
-
@mzimmers said in bad syntax on connect() statement:
QObject::connect(s, &Serial::newText, w, &Widget::addText);
I'm pretty sure you must specify the address of s and w:
QObject::connect(&s, &Serial::newText, &w, &Widget::addText);