Results 1 to 7 of 7

Thread: How to activate another process?

  1. #1
    Join Date
    Jan 2006
    Posts
    29
    Qt products
    Qt4
    Platforms
    Windows

    Default How to activate another process?

    I have the process A, it started the process B at begining of program using QProcess. And now, I want that when I click a button in the process A, the process B (running) will be activated immediately. Has any way to do that?
    Thanks for reading.

  2. #2
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: How to activate another process?

    If you start process B in begin of process A then what you mean under "activate"? Do you want send some data to process B?

  3. #3
    Join Date
    Jan 2006
    Posts
    29
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to activate another process?

    I mean that the main window/dialog of the process B will be shown on top and receives the mouse/keyboard focus immediately.
    Thanks very much.

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to activate another process?

    from the docs of QProcess (Qt4) it looks like it could be done with write() and read()...

  5. #5
    Join Date
    Jan 2006
    Location
    Athens - Greece
    Posts
    219
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to activate another process?

    Quote Originally Posted by high_flyer
    from the docs of QProcess (Qt4) it looks like it could be done with write() and read()...
    That should trigger a call to
    Qt Code:
    1. void QWidget::activateWindow ()
    To copy to clipboard, switch view to plain text mode 
    Something like:
    Qt Code:
    1. Process A starts Process B
    2. Process receives the button clicked signal and writes a message to Process B stdin
    3. Process B calls void QWidget::activateWindow() for the widow/widget you want to receive keyboard focus
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Jan 2006
    Posts
    29
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to activate another process?

    Thanks everyone, but I still have some questions.

    To yop:
    - Where should I call to QWidget::activeWindow() in code of the process B?
    - How can the process B know that the process A has just written a message to it?

    I really want the process B is controlled by A. (The process A needs to show some dialogs of B like its dialogs). I intend to use a shared memory between 2 processes. When the process A wants to force B into doing something, it'll writes the messages/commands into the shared memory. The process B'll have a thread checks this shared memory continuously to receive the messages from the process A and will show the corresponding dialogs. But I think that the dialogs of the process B will not show on top to receive keyboard focus as I expect.

  7. #7
    Join Date
    Jan 2006
    Location
    Athens - Greece
    Posts
    219
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to activate another process?

    Quote Originally Posted by gtthang
    - Where should I call to QWidget::activeWindow() in code of the process B?
    Just realized you're using windows:
    On Windows, if you are calling this when the application is not currently the active one then it will not make it the active window. It will change the color of the task bar entry to indicate that the window has changed in some way. This is because Microsoft do not allow an application to interrupt what the user is currently doing in another application.
    Sorry, blaim Bill
    To answer your question, when process B is triggered it should be called from the widget you want shown.
    Quote Originally Posted by gtthang
    - How can the process B know that the process A has just written a message to it?
    Use stdin or a socket.

Similar Threads

  1. How to communicate Qt Process with non-qt process
    By nrabara in forum Qt for Embedded and Mobile
    Replies: 9
    Last Post: 15th February 2009, 21:01
  2. Process Read/Write
    By QbelcorT in forum Newbie
    Replies: 0
    Last Post: 20th November 2008, 03:08
  3. Replies: 1
    Last Post: 13th September 2008, 14:45
  4. Problem executing process
    By EricF in forum Qt Programming
    Replies: 4
    Last Post: 25th January 2008, 16:04
  5. Send a key to process
    By Nyphel in forum Qt Programming
    Replies: 2
    Last Post: 9th July 2007, 17:37

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.