Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, April 2008
connect failed to a slot


Message 1 in thread

Hi,
I have the following virtual class:
class ILeg : public QObject
  {
    private:
      Q_OBJECT
    public slots:
      virtual void NameAndDrivers() = 0;
      virtual void InitPlugins() = 0;
      virtual void Start() = 0;
      virtual void Stop() = 0;
    signals:
      void Time(int time);
      void NewDriver(QString clubName, QString driverAlias, int transponder,
int frequency);
      void LegName(QString string);
      void LapCheckpoint(QString string);
      void RaceEvent(QString string);
      void ClearCars();
  };

The follwing class implements ILeg
class Leg : public ILeg
{
//implements ILeg among other things
}

In other class I retrieve the ILeg interface from my leg and do the
following
ILeg * Leg = ... retrieve ILeg Interface
if (leg != NULL)
      {
         connect(leg, SIGNAL(Time(int)),
                                 auxLeg, SLOT(UpdateTime(int)));

         connect(leg, SIGNAL(NewDriver(QString, QString, int, int)),
                                 auxLeg, SLOT(AddCar(QString, QString, int,
int)));

         connect(leg, SIGNAL(LegName(QString)),
                                 auxLeg, SLOT(LegName(QString)));

         connect(leg, SIGNAL(LapCheckpoint(QString)),
                                 auxLeg, SLOT(NewLapCheckpoint(QString)));

         connect(leg, SIGNAL(RaceEvent(QString)),
                                 auxLeg, SLOT(NewRaceEvent(QString)));

         connect(leg, SIGNAL(ClearCars()),
                                 auxLeg, SLOT(ClearCars()));

         connect(auxLeg, SIGNAL(StartRace()),
                 leg, SLOT(Start()));
}

//all connects from the leg to auxLeg Work, but the las connect auxLeg to
leg dosn't work at all, (No error at connection in the terminal, etcetera).
StartRace signal is emited here:
void UILeg::on_legStartButton_clicked(bool checked){
       printf("StartRace Clicked\n");
       emit StartRace();
   }
When I press the button the printf is correctly printed in the terminal:
the Start() slot does the following:
void Leg::Start(){
    printf("Start\n");
    if (m_input != NULL)
    {
      printf("Start NOT NULL\n");
      m_input->StartRace(this);
    }
}
The test string Start is not printed at all, (and m_input->StartRace())
doesn't work at all)
but if from the class that retrieves the ILeg interface I call directly to
the Start method (leg->Start()) it works correctly
Any explanation, sugestion?

Thanks in advance
Pablo.

Message 2 in thread

On Thu, Apr 3, 2008 at 4:55 PM, Pablo Gavela <lewiatan@xxxxxxxxx> wrote:

> //all connects from the leg to auxLeg Work, but the las connect auxLeg to
> leg dosn't work at all, (No error at connection in the terminal, etcetera).

Have you checked the return value of that connect function call?

Also, can you show the definition of the class that implements the interface?

-- 
 [ signature omitted ]