I'm currently working on my first GUI cpp application using QT. Right now my aim is to display a dialogue to the user with two buttons: Ok and Cancel. I've used signal and slot editor to make cancel close the window, however what I can't seem to find and manage to do is to run a function from another .cpp file when OK is being clicked. I've googled it and no answers seem to be relevant.
file "mydefault.cpp" -
\\ call function from another .cpp file
This is important thing to understand in C / C++ (as opposed to Java, etc). Each .c/.cpp file is compiled separately, then linked together. When the mydefault.cpp is being compiled, it needs to know that the calldefaults() function exists. To do that, you need what's called a "prototype". At the beginning of the mydefault.cpp file, outside of any function declaration, put a line that looks like:
void calldefaults ();
and call the function like:
That will work - if you have linking issues, ensure both files are included in your compiler command.