Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to call a function.
Qt 6.11 is out! See what's new in the release blog

How to call a function.

Scheduled Pinned Locked Moved General and Desktop
9 Posts 4 Posters 2.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tyler1234
    wrote on last edited by
    #1

    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!

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #2

      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.

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • T Offline
        T Offline
        Tyler1234
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • V Offline
          V Offline
          vezprog
          wrote on last edited by
          #4

          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":http://www.cplusplus.com/ 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.

          1 Reply Last reply
          0
          • T Offline
            T Offline
            Tyler1234
            wrote on last edited by
            #5

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

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

            1 Reply Last reply
            0
            • G Offline
              G Offline
              giesbert
              wrote on last edited by
              #6

              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?

              Nokia Certified Qt Specialist.
              Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

              1 Reply Last reply
              0
              • T Offline
                T Offline
                Tyler1234
                wrote on last edited by
                #7

                Ok, thank you

                To run some code when the program launches.

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  giesbert
                  wrote on last edited by
                  #8

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

                  Nokia Certified Qt Specialist.
                  Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    ambershark
                    wrote on last edited by
                    #9

                    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()
                    {
                    myFunc();
                    return 0;
                    }
                    @

                    But that has absolutely nothing to do with Qt.

                    My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved