More gui slot problems

I’ve done some searches on this topic and I’ve tried all the advice I could find. I’m having a problem with the basic gui example in compiled code only . It runs fine straight through root and all the buttons work but if I try to make it stand-alone the window is created but I get the following error:

Error in TQObject::CheckConnectArgs: slot DoDraw() does not exist
And of course the draw button doesn’t work.

Now I’ve looked at my pragma linkDef and it looks ok. I’ve also got a dictionary file that looks ok (there’s a similar thread active in the forum). I’ve included the makefile that generates it and can post it if necessary (it’s pretty long).
I just can’t seem to find the problem. I’ve tried adding in the “ClassDef” and that returns only errors.

Here are all the files:

MyMainFrame.cxx
#include <TApplication.h>
#include <TGClient.h>
#include <TQObject.h>
#include <TCanvas.h>
#include <TF1.h>
#include <TRandom.h>
#include <TGButton.h>
#include <TRootEmbeddedCanvas.h>
#include “MyMainFrame.h”

MyMainFrame::MyMainFrame(const TGWindow *p,UInt_t w,UInt_t h) : TGMainFrame(p,w,h)
{
// Create a main frame
// fMain = new TGMainFrame(p,w,h);

// Create a canvas widjet
fEcanvas = new TRootEmbeddedCanvas(“Ecanvas”,this,200,200);
AddFrame(fEcanvas, new TGLayoutHints(kLHintsExpandX
| kLHintsExpandY,100,1,1,50));
// Create a horizontal frame widget with buttons
TGHorizontalFrame *hframe = new TGHorizontalFrame(this,200,40);
TGTextButton *draw = new TGTextButton(hframe,"&Draw");
draw->Connect(“Clicked()”,“MyMainFrame”,this,“DoDraw()”);
hframe->AddFrame(draw, new TGLayoutHints(kLHintsCenterX,5,5,3,4));
TGTextButton *exit = new TGTextButton(hframe,"&Exit",“gApplication->Terminate(0)”);
hframe->AddFrame(exit, new TGLayoutHints(kLHintsCenterX,5,5,3,4));
AddFrame(hframe, new TGLayoutHints(kLHintsCenterX,2,2,2,2));
// Set a name to the main frame
SetWindowName(“DSSSD Calibration Program”);

// Map all subwindows of main frame
MapSubwindows();

// Initialise the layout algorithm
Resize(GetDefaultSize());

// Map main frame
MapWindow();
}

void MyMainFrame::DoDraw()
{
// Draws function graphics in randomly choosen interval
TF1 *f1 = new TF1(“f1”,“sin(x)/x”,0,gRandom->Rndm()*10);
f1->SetFillColor(19);
f1->SetFillStyle(1);
f1->SetLineWidth(3);
f1->Draw();
TCanvas *fCanvas = fEcanvas->GetCanvas();
fCanvas->cd();
fCanvas->Update();
}

MyMainFrame::~MyMainFrame()
{
//Clean up used widgests: frames, buttons, layouthints
Cleanup();
}

int main(int argc, char **argv)
{
TApplication theApp(“App”,&argc,argv);
new MyMainFrame(gClient->GetRoot(),200,200);
theApp.Run();
return 0;
}

MyMainFrame.h
#include <TGFrame.h>
#include <TRootEmbeddedCanvas.h>

#ifndef MYMAINFRAME_H
#define MYMAINFRAME_H

class TGWindows;
class TGMainFrame;
class TRootEmbeddedCanvas;

class MyMainFrame : public TGMainFrame {

public:
MyMainFrame();
MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h);
virtual ~MyMainFrame();
void DoDraw();

private:
// TGMainFrame *fMain;
TRootEmbeddedCanvas *fEcanvas;

// ClassDef(MyMainFrame,1)
};

#endif

Makefile:
all : example # MyMainFrame.so

CFLAGS = (shell root-config --cflags) LIBS = (shell root-config --libs)
GLIBS = $(shell root-config --glibs)

%Cint.cxx:Include.h LinkDef.h
rootcint -f @ -c ^

example : MyMainFrame.o MyMainFrameDict.o
g++ $(shell root-config --cflags --glibs --libs) -o example MyMainFrame.o

MyMainFrame.o : MyMainFrame.cxx MyMainFrame.h
g++ $(shell root-config --cflags) -c MyMainFrame.cxx -o MyMainFrame.o

MyMainFrameDict.o : MyMainFrameDict.C
g++ $(shell root-config --cflags) -c MyMainFrameDict.C -o MyMainFrameDict.o

MyMainFrameDict.C : MyMainFrameLinkDef.h

%Dict.C : %.h %LinkDef.h
rootcint -f @ -c *.h $*LinkDef.h

.PHONY : clean
clean :
rm -f example MyMainFrame.o MyMainFrameDict.o MyMainFrameDict.cxx

MyMainFrameLinkDef.h
#ifdef CINT
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;

#pragma link C++ class MyMainFrame;
#endif

Any help would be vastly appreciated! [-o<

Hi,

Please find your files attached with some fixes in MyMainFrame.cxx, MyMainFrame.h and Makefile.

Cheers, Ilka

Thanks so much for the quick reply! I think I’ve finally figured out everything you’ve changed…!

:open_mouth:

\:D/