Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to invoke main function of different project
Forum Update on Monday, May 27th 2025

How to invoke main function of different project

Scheduled Pinned Locked Moved Solved Mobile and Embedded
8 Posts 4 Posters 1.5k Views
  • 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.
  • S Offline
    S Offline
    Sherlin N G
    wrote on last edited by
    #1

    When a button is clicked in the ui how do i invoke main of other project? Is it possible?

    JonBJ 1 Reply Last reply
    0
    • S Sherlin N G

      When a button is clicked in the ui how do i invoke main of other project? Is it possible?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Sherlin-N-G
      The "other project" is a completely separate, standalone executable?

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Sherlin N G
        wrote on last edited by
        #3

        it is a standalone project.

        JonBJ jsulmJ 2 Replies Last reply
        0
        • S Sherlin N G

          it is a standalone project.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @Sherlin-N-G
          So if it produces a standalone executable, surely all you can do is invoke that executable (as an OS command)? Unless you want to change its code to refactor it (e.g. into a standalone library) such that you call its functionality through some function rather than main.

          1 Reply Last reply
          2
          • S Sherlin N G

            it is a standalone project.

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @Sherlin-N-G You can't call main of another executable. You need to start it as own process. Take a look at http://doc.qt.io/qt-5/qprocess.html

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            2
            • yuvaramY Offline
              yuvaramY Offline
              yuvaram
              wrote on last edited by
              #6

              @Sherlin-N-G
              Make a executable of the project which you want to call other main function.
              Call the executable using QProcess

              QString program = "./path/to/Qt/examples/widgets/analogclock";
              QStringList arguments;
              arguments << "-style" << "fusion";

              QProcess *myProcess = new QProcess(parent);
              myProcess->start(program, arguments);
              

              Yuvaram Aligeti
              Embedded Qt Developer
              : )

              1 Reply Last reply
              2
              • S Offline
                S Offline
                Sherlin N G
                wrote on last edited by Sherlin N G
                #7

                Hi, Thanks for the reply.Problem solved

                yuvaramY 1 Reply Last reply
                0
                • S Sherlin N G

                  Hi, Thanks for the reply.Problem solved

                  yuvaramY Offline
                  yuvaramY Offline
                  yuvaram
                  wrote on last edited by
                  #8

                  @Sherlin-N-G
                  change the post to solved state

                  Yuvaram Aligeti
                  Embedded Qt Developer
                  : )

                  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