Qt5.3 Signal and Slots + Parameters
-
Ok having a bit of problems with connecting two parts of my program together firstly we have below the emitted signal being used (which i presume is correct).
@CCTVForm * lCCTVForm = fFormController->getGUIForm();
const uint8_t * lLCID = aLCID.value();*lCCTVForm << "LC Select - Check\r\n" << "\tSequence Number: " << static_cast< int >(aSequenceNumber.value()) << "\r\n" << "\tLCID: " << static_cast< int >(lLCID[0]) << static_cast< int >(lLCID[1]) << static_cast< int >(lLCID[2]) << static_cast< int >(lLCID[3]) << "\r\n" << "\tLC Name: " << aName << "\r\n" << "\tCamera 1: " << aCamera1.lcid().id() << "\r\n" << "\tCamera 2: " << aCamera2.lcid().id() << "\r\n" << sendToForm; emit emit_camera_info(aCamera1.lcid().id(),aCamera2.lcid().id());@
Inside the .hpp file
@signals:
void emit_camera_info(QString,QString);@Then on my cctv form I want to be able to pass the two camera LCID's to CCTVForm.
@ // Create the widgets
cctv_mplayer_wrapper *Cameras = new cctv_mplayer_wrapper();// Add to the form centralWidget()->layout()->addWidget(Cameras); CCTVController *Control = new CCTVController(); QObject::connect(Control,&CCTVController::emit_camera_info(QString,QString), this,&CCTVForm::update_camera_info(QString,QString));
//
//
Cameras->set_rtsp_path_cam_1("rtsp://169.254.133.191/output");
Cameras->set_rtsp_path_cam_2("rtsp://169.254.133.193/output");
Cameras->start_mplayer();@.hpp file
@void update_camera_info(QString Camera1, QString Camera2);@It's currently failing with
bq. C:\Software\lxc - Copy\cctv\src\cctv_form.cpp:274: error: expected primary-expression before ',' token
QObject::connect(Control,&CCTVController::emit_camera_info(QString,QString),this,&CCTVForm::update_camera_info(QString,QString));As you can imagine I'm a bit lost on this as it seems to me to be a correct connect statement. If anyone has an idea how this is caused I would be very grateful.
-
Hi,
You are mixing up the two syntaxes to connect signals and slots.
The first form uses macros and needs function parameters:
@QObject::connect(&a, SIGNAL(valueChanged(int)),&b, SLOT(setValue(int)));@
The second form uses pointer to member functions and doesn't parameters:
@ QObject::connect(&a, &Counter::valueChanged,&b, &Counter::setValue);@
Good luck!