#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; class MyClass : public TGMainFrame { public: MyClass(); virtual ~MyClass(); void ChangeLabelText(); private: static void* ThreadHandle(void *arg); void InitWindow(); TThread *myThread; TGLabel *fLabel; bool fChanged; }; MyClass::MyClass() : TGMainFrame(gClient->GetRoot(), 400, 400),fChanged(false) { InitWindow(); //this creates different frames, labels etc. cout<<"Initialized"<Run(); cout<<"thread running"<(arg); while(1) { classInstance->ChangeLabelText(); sleep(5); } return nullptr; } void MyClass::ChangeLabelText() { if(!fChanged) { cout<<"1"<SetText("new text"); fChanged=true; } else { cout<<"2"<SetText("old text"); fChanged=false; } } void MyClass::InitWindow() { SetCleanup(kDeepCleanup); fLabel = new TGLabel(this,"Text 1"); AddFrame(fLabel,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY)); SetWindowName("Main Window"); MapSubwindows(); Resize(100,100); MapWindow(); } int main(int argc,char **argv) { TApplication app("Application", &argc, argv); MyClass *mainWindow = new MyClass(); app.Run(kTRUE); if(mainWindow) delete mainWindow;mainWindow=0; return 0; }