How to call a function.

  • I need to know how to call a function from the function main. the function I want to call can be anywhere it can be put, I just want it to work!

  • This is C / C++ standard.
    What exactly do you try to do?

    If you want to call a function, call it. If you want to call a method, call it onthe object.

  • I am using c++
    just call the function from main so the function runs soon as the program starts.

    could you please give me an example.

  • As Qt is just C++, maybe you should read up how to program C++ before you dip your feet into the Qt libraries. Or learn them concurrently (no pun intended).

    "This": website has some great C++ tutorials.

    The Qt examples that are packaged with the libraries are another great reference. They should be right in your Qt install directory under your Qt version.

  • I do know c++ but I am verry new to Qt

    Are you saying it is the same as c++?

  • Qt is just a C++ framework.
    If you know C++, you know how to call a function.

    What exactly do0 you want to achieve with this?

  • Ok, thank you

    To run some code when the program launches.

  • Write the function call in main() ... ?

  • Moderators

    Are you talking about a specific function? Or one from Qt?

    Like Gerolf says this is basic C/C++, if you wanted to call a function from main it would be:

    int main()
    return 0;

    But that has absolutely nothing to do with Qt.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.