PDA

View Full Version : Connecting to a slot not within an Obejct



Matze-o
10th November 2008, 09:57
Hello

I have a MainWindow with slots and signals and QThread. I have no problem connecting signals from my thread (Control_C) with slots from my mainWindow.



connect(this, SIGNAL(connected()), myMainWindow_p, SLOT(establishedConnection()));
connect(this, SIGNAL(disconnected()), myMainWindow_p, SLOT(closedConnection()));

But the other way around won't work:



connect(actionVia_CAN_Bus, SIGNAL(triggered()), myControl_p, SLOT(establishConnectionCan()));
connect(actionVia_RS_232, SIGNAL(triggered()), myControl_p, SLOT(establishConnectionRs232()));
connect(actionDisconnect, SIGNAL(triggered()), myControl_p, SLOT(closeConnection()));

I get:error C2664: 'bool QObject::connect(const QObject *,const char *,const QObject *,const char *,Qt::ConnectionType)'

Converting from object to Control_C impossible. That makes sense, obviously. But is there a workaround?

Thanks in advance.

edit: solved i had to use a cast operator (QObject *)myControl_p

pastor
10th November 2008, 10:13
Make sure, that you added include file with Control_C declaration.

Sheng
10th November 2008, 14:02
Did you use QThread for your thread object? did you add Q_OBJECT?