Whar is this error saying?
-
So - it is an error , but why compiler complains about BOTH "()" ?
Please no other subject s - I just want to know this about both "()" .
/mnt/A_BT_DEC10/BT__PROGRAMS/A_JAN11/A_BT_LIBRARY/terminal_Bluetooth/mainwindow_Bluetooth.cpp:3665: error: expected '(' for function-style cast or type construction mainwindow_Bluetooth.cpp:3665:34: error: expected '(' for function-style cast or type construction connect(tempmenu, triggered(bool), this, &MainWindow_Bluetooth::openSerialPort); ~~~~^
-
@AnneRanch said in Whar is this error saying?:
but why compiler complains about BOTH "()" ?
Because you still don't understand how signals and slots work... the second argument must be a pointer member function as you already did for the forth parameter.
-
@AnneRanch
Luckily, menu creation is still in short-term memory. So I have a remote idea, whattempmenu
actually is ;-)=> change the line to
connect(tempmenu, &QMenu::triggered, this, &MainWindow_Bluetooth::openSerialPort);
-
@Axel-Spoerl Thanks , I wad actually triggering on wrong action before. I guess I will never know why I how to read the "() " error to correct my code.
.
( I guess I posted this wrong and despite my request (i GOT "how to write connect advises I DID NOT ASK FOR" .Thanks Axel
-
@AnneRanch
The error message you got when you wrotetriggered(bool)
in yourconnect()
is simply because the compiler cannot match any of the available overloads ofconnect()
to one which would accept anything liketriggered(bool)
as the actual parameter. In itself, like many C++ compiler errors the wording is a bit abstruse/not terribly helpful, because the language is complicated. -
@AnneRanch said in Whar is this error saying?:
Thanks , I wad actually triggering on wrong action before. I guess I will never know why I how to read the "() " error to correct my code.
The compiler is actually exactly telling you why it has a problem with the (missing) brackets, I'll quote the part:
cpp-compiler said in mainwindow_Bluetooth.cpp
error: expected '(' for function-style cast or type construction
it thinks your bool is an attempt of you to cast something to an boolean and it thinks the silly programmer forgot to add the bracket and the actual variable that is supposed to be cast.
something like this:
int a = 0; auto b = bool(a);
or in your particular case:
void triggered(bool variable) { qDebug() << variable } .... int a = 0; triggered(bool(a));
The compiler doesn't know that function style cast do only the other people, true c++ programers don't use it at all.