Results 1 to 2 of 2

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

  1. #1
    Join Date
    Jul 2010
    Location
    /home/hakermania/
    Posts
    233
    Thanks
    129
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

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

    Hello Developers

    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
    When you 're trying to help somebody in the newbie section, don't forget that he is a newbie. Be specific and give examples.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

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

    Quote Originally Posted by hakermania View Post
    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.
    Like http://doc.trolltech.com/solutions/4...plication.html or http://www.qtcentre.org/wiki/index.p...gleApplication.

    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)
    From your description I am not entirely sure I know what your problem actually is. How your application should behave if you start multiple instances is entirely up to you.

Similar Threads

  1. Replies: 5
    Last Post: 10th January 2011, 00:19
  2. ensure that only one instance of program is running
    By alireza.mirian in forum Qt Programming
    Replies: 4
    Last Post: 5th January 2011, 18:53
  3. Replies: 2
    Last Post: 28th May 2010, 09:16
  4. Qt4 'breaks' command line program
    By kachofool in forum Newbie
    Replies: 7
    Last Post: 13th November 2009, 20:56
  5. Replies: 5
    Last Post: 16th January 2006, 05:15

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.