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
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
Code:
if ( ! pointerToD2 ) {
// D2 is not yet created !
// May be U can create it here
}
pointerToD2->updateTheContents( params );
Re: instance of an application is running or not????
ok....how to access the pointer to D2 from main.cpp.
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 :confused:
Any way
Code:
int main() {
D1 d1;
d1.d2->updateContents()
}
Please recheck the Design before u decide to do this !!
Re: instance of an application is running or not????
If you need interaction between two dialogs use the singleton pattern :
mydialog.h
Code:
#include <QtCore>
#include <QtGui>
{
Q_OBJECT
public:
static mydialog* Instance()
// your stuffs here
private:
static mydialog *inst;
}
mydialog.cpp
Code:
mydialog mydialog:: *inst = 0;
mydialog* mydialog::Instance()
{
if (inst == 0)
inst = new mydialog;
return inst;
}
constructors and destructors are declared private
1 Attachment(s)
Re: instance of an application is running or not????
Check the code
pm me if you have any doubts :)