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 only launch one instance of my program
QtWS25 Last Chance

How to only launch one instance of my program

Scheduled Pinned Locked Moved General and Desktop
9 Posts 6 Posters 3.2k 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.
  • K Offline
    K Offline
    kloveridge
    wrote on last edited by
    #1

    While I get the value of Qt Creator not shutting down previous executions of my application everytime I run or debug my application, this feature gets a little annoying. If I don't pay attention, I can have a dozen instances of my applicatoin runnin simultaneously! Is there a way to make Qt Creator shut down the previous tested application before launching a new one?

    In Xcode, everytime I launch my application, it first shuts down the previously executed application and starts a new instance of my app.

    Can Qt Creator do the same?

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

      what do you mean "Creator not shutting down previous executions of my application everytime I run or debug my application"? you can't even press the "run" or "debug" buttons while an application is running (started with creator's "run" or "debug" buttons)

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        kloveridge means that the current running instance is not killed if you restart your application e.g. rebuilding and running it.

        It might be question better suited for the Qt Creator mailing list

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • K Offline
          K Offline
          kloveridge
          wrote on last edited by
          #4

          Mad Scientist has it right.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            "Mad Scientist" is just a rank ;)

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #6

              [quote author="SGaist" date="1411934198"]"Mad Scientist" is just a rank ;)[/quote]

              I'd say in your case it's true ;-)

              (Z(:^

              1 Reply Last reply
              0
              • TheBadgerT Offline
                TheBadgerT Offline
                TheBadger
                wrote on last edited by
                #7

                If the requirement is "only one instance of the application" even when not running it through Qt Creator, look at the qtsingleapplication solution that is part of the "Qt Solutions Archive":https://qt.gitorious.org/qt-solutions.

                If it is only related to Qt Creator, I would second SGaist and ask on the Creator Mailing List


                Check out my SpellChecker Plugin for Qt Creator @ https://github.com/CJCombrink/SpellChecker-Plugin

                1 Reply Last reply
                0
                • F Offline
                  F Offline
                  Francknos
                  wrote on last edited by
                  #8

                  I have something for you.

                  I use this to do that:
                  @
                  QProcess x;
                  x.start("tasklist");
                  x.waitForStarted(200); //1000 avant
                  x.waitForReadyRead(200);
                  x.waitForFinished(200);
                  QString result( x.readAllStandardOutput() );
                  if(result.count("YOUR_APPLICATION.exe",Qt::CaseInsensitive) >=2 )
                  {
                  popupMessage(tr("This application is already running!"),2000,this);
                  QTimer::singleShot(2000, qApp, SLOT(quit()));
                  }
                  @

                  I hope this will help you.

                  1 Reply Last reply
                  0
                  • K Offline
                    K Offline
                    kloveridge
                    wrote on last edited by
                    #9

                    I will give this a try. Thanks for your help!

                    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