Am I calling this method wrong?
-
Hi and welcome to the forum,
it's always better to post code as text using the code format button ( "
</>").
Anyway, it's seems that you are not that familiar with C++ and or OOP programming languages.There's a lot stuff going on in you code which is wrong.
-
The call to
Ui->cmbPorts....in yourforeachloop does not work like this, because your UI's namespace is namedUi, but not the pointer/instance to your actual compiled Ui class... -
And even then... you should only access the UI from the same class directly.
You are inserial.cpp, while theui, even if spelled correctly, is a private member ofMainWindow. It cannot (and should not) be accessed fromserial. -
Your
openPort()method inserial.cppis not even a member function of theserialclass... it's just a globally declared function floating around in yourserial.cppfile... which is another issue here... -
therefore the call
serial1.openPort()doesn't work... because there is noserial::openPort(), as I explained above -
also your
serialclass is missing a constructor... we can't see yourserialheader, but since you are showing the code file, which contains no class/member functions at all, I doubt it's there.
The error in your 3rd picture even says "undefined reference to serial::serial"
Might sound harsh, but I would recommend to learn the C++ basics (Objects, Pointers, Classes, Members, Inheritance and other OOP principles) and then come back before you dive further into Qt now, struggling with small things which are obligatory to work with Qt (and not get frustrated)
So to answer your question "
Am I calling this method wrong?", yes and a couple more mistakes@Comedian are you more familiar with Python?!
Have a look at the Python wrapper for Qt called "PySide"Here are some helpful links:
-
-
@Comedian One more observation: in on_portQuery_clicked() you create a local variable and then call openPort() on it. This local variable only lives inside on_portQuery_clicked() and will be deleted as soon as on_portQuery_clicked() finishes.