[Qt-interest] Signal Slot not working

Luis Lezcano Airaldi luislezcair at gmail.com
Mon Jun 21 02:33:27 CEST 2010


El 20/06/10 18:09, Matthias Pospiech escribió:
> I have a dll emitting error messages:
>
> void QMicosPolluxController::Error(const char * errorMessage)
> {
>      emit errorOccurred(toQString(errorMessage));
> }
>
>
> which is handled in the gui (using the dll)
> void DialogMicosController::connectSignalSlots()
> {
>      connect(controller, SIGNAL(errorOccurred(QString)), this,
> SLOT(OnControllerError()));
> }
> void DialogMicosController::OnControllerError(QString error)
> {
>      ui->labelError->setText(error);
> }
>
> However the function OnControllerError is never called.
> If I copy all classes to the gui project (thus no dll), the effect is
> exactly the same.
> The SLOT is never called
>    

The signal emits a const char*, so I think the slot should take a const 
char* parameter or a const QString& (a constant reference).

And, of course, make sure your class inherits from QObject and you have 
the Q_OBJECT macro in your class.

Regards.



More information about the Qt-interest-old mailing list