Results 1 to 6 of 6

Thread: instance of an application is running or not????

  1. #1
    Join Date
    Jan 2006
    Posts
    2
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default instance of an application is running or not????

    hi all,
    The application is being developed in Linux and to explain the problem in more detail..application has 2 dialog windows(D1 & D2).Note that D2 is dynamically created based on an event taking place on D1.I come across a situation where I have to update the content displayed on D2 that is already running.I would like to know how to identify whether an instance of D2 is already runnin.The caption on each of the D2(s) that is generated are different.
    Any help would be appreciated...

    thanx and rgards,
    sinche

  2. #2
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Thanks
    76
    Thanked 37 Times in 32 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: instance of an application is running or not????

    You will have to maintain a pointer to the D2 and use it to update the Contents of D2

    Qt Code:
    1. if ( ! pointerToD2 ) {
    2. // D2 is not yet created !
    3. // May be U can create it here
    4. }
    5.  
    6. pointerToD2->updateTheContents( params );
    To copy to clipboard, switch view to plain text mode 
    We can't solve problems by using the same kind of thinking we used when we created them

  3. #3
    Join Date
    Jan 2006
    Posts
    2
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: instance of an application is running or not????

    ok....how to access the pointer to D2 from main.cpp.

  4. #4
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Thanks
    76
    Thanked 37 Times in 32 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: instance of an application is running or not????

    Could u please explain what do intend to Do ?

    Since accessing a pointer to a Form Created within Another is very Rare

    Any way
    Qt Code:
    1. int main() {
    2. D1 d1;
    3. d1.d2->updateContents()
    4. }
    To copy to clipboard, switch view to plain text mode 

    Please recheck the Design before u decide to do this !!
    Last edited by sunil.thaha; 12th January 2006 at 09:38.
    We can't solve problems by using the same kind of thinking we used when we created them

  5. #5
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: instance of an application is running or not????

    If you need interaction between two dialogs use the singleton pattern :

    mydialog.h
    Qt Code:
    1. #include <QtCore>
    2. #include <QtGui>
    3.  
    4. class mydialog : public QDialog
    5. {
    6. Q_OBJECT
    7.  
    8. public:
    9. static mydialog* Instance()
    10.  
    11. // your stuffs here
    12.  
    13. private:
    14. static mydialog *inst;
    15. }
    To copy to clipboard, switch view to plain text mode 

    mydialog.cpp
    Qt Code:
    1. mydialog mydialog:: *inst = 0;
    2.  
    3. mydialog* mydialog::Instance()
    4. {
    5. if (inst == 0)
    6. inst = new mydialog;
    7. return inst;
    8. }
    To copy to clipboard, switch view to plain text mode 

    constructors and destructors are declared private
    Current Qt projects : QCodeEdit, RotiDeCode

  6. #6
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Thanks
    76
    Thanked 37 Times in 32 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: instance of an application is running or not????

    Check the code
    pm me if you have any doubts
    Attached Files Attached Files
    We can't solve problems by using the same kind of thinking we used when we created them

Similar Threads

  1. How to detect a running application
    By yogesh in forum Qt Programming
    Replies: 4
    Last Post: 20th February 2009, 11:22
  2. How to invoke a running application
    By srikanthch in forum Qt Programming
    Replies: 2
    Last Post: 18th December 2008, 16:42
  3. Replies: 7
    Last Post: 24th November 2008, 12:22
  4. Replies: 5
    Last Post: 9th June 2008, 12:21
  5. Replies: 10
    Last Post: 11th June 2007, 10:18

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.