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. Program is running in command line mode and another instance is launched!?
Forum Updated to NodeBB v4.3 + New Features

Program is running in command line mode and another instance is launched!?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.0k 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.
  • A Offline
    A Offline
    alexandros
    wrote on last edited by
    #1

    Hello Developers :D

    I have developed an application that takes command-line arguments.
    The application has the ability to focus to the already running application if another instance is launched, by sending a message from the launched (new) application to the already open application.
    So, the problem is that if the program is running with a command line argument (something that does not open the GUI, it runs in the console) and another instance is launched I don't know what to do exactly...
    The argument is running a function every 30min using a qtimer and does nothing else actually, so, should I have the app connected and ready to receive a signal and when it receive it from the another instance to call the w.show(); (where w is MainWindow w;) and stop the command line-mode and its functionality (also maybe display a message that the process X has stopped because another instance was launched) ?

    I think that this is what I should do but not sure, and I don't want to do something wrong and have to correct it afterwards... (also by doing my way of thinking, MainWindow w; should be global)

    So, what would be your way to do it, or what do you expect to be the behaviour of a program if it had a command-line interface and GUI was called?

    Thanks :)

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tobias.hunger
      wrote on last edited by
      #2

      Are you looking for something like "this":http://doc.qt.nokia.com/solutions/4/qtsingleapplication/qtsingleapplication.html?

      1 Reply Last reply
      0
      • A Offline
        A Offline
        alexandros
        wrote on last edited by
        #3

        Thank Tobias for the answer!
        No! The problem is specific :)
        I have my own (really safe, no files used) way to check if my application is running.

        I don't need this.

        I want your opinion about what would you have done in an occassion where your program was running in non-GUI mode and GUI was called, and briefly how would you do it (I have mentioned my way in the 1st post)

        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