Hello Rooters,
I want to use the Signal/Slot mechanism to send TStrings in Order to collect information of Classes in a “Log Window”. Below is an example of what I am trying to do.
MyAgat.cpp file[code]//________________________________________________
MyAgat::MyAgat(const TGWindow *p, int w, int h)
:MyAgatWin(p,w,h)
{
start->Connect(“Clicked()”,“MyAgat”,this,“test2()”);
this->Connect(“test(TString)”,“MyAgat”,this,“writeLog(TString)”);
}
//________________________________________________________
void MyAgat::writeLog(TString text)
{
TDatime time;
text.Prepend(": ");
text.Prepend(time.AsSQLString());
outLog->AddLine(text.Data());
}
void MyAgat::test(TString te)
{
Emit(“test(TString)”,te);
}
void MyAgat::test2()
{
test(“hello World”);
}
[/code]
MyAgat.h file[code]class MyAgat
{
public:
MyAgat(const TGWindow *p, int w, int h);
virtual ~MyAgat();
void test(TString); //*SIGNAL*
void test2();
void writeLog(TString text);
ClassDef(MyAgat,0) //Main Window Program Part
};
[/code]
Start is a TGTextButton. Everytime is click on Start the program crashes. But when Replace the text in test2() to writeLog(“hello world”); It works fine.
What do I do wrong?