Connecting signals and slots with different parameters: Is it possible?
-
HI,
I wish to make a connection, and I'm aware that they both must have the same type of parameter in order to work. My question is:
Is there a way, or workaround, to this issue?
In my project, I want to connect a simple valuechanged signal to a a slot that receives 3 QWidet parameters.
This is the code in question://OperatorLogged is a valuechanged signal, nothing weird. connect(login, SIGNAL(operatorLogged(int)), this, SLOT(createOperatorInterface(QWidget*, QWidget*, QWidget*))); //createOperatorInterface takes the QWidget arguments and adds them to "this" stacked layout. "This" being the main widget, by the way.I would also like to know if using the main.cpp is the best practice, as I was taught in OOP, to work with my code. The whole issue comes from me trying to work in the main.cpp like this:
#include "mainwidget.h" #include "qlogin.h" #include "qdispense.h" #include "qdispensedisplay.h" #include "qresult.h" #include <QApplication> #include <QCalendarWidget> int main(int argc, char *argv[]) { QApplication Skylord(argc, argv); mainWidget mwMainWidget; mwMainWidget.show(); QLogin *loginWidget = new QLogin; QDispense *dispenseWidget = new QDispense; QDispenseDisplay *dispenseDisplayWidget = new QDispenseDisplay; QResult *resultWidget = new QResult; mwMainWidget.createLogin(loginWidget); return Skylord.exec(); }Thanks in advance.
-
HI,
I wish to make a connection, and I'm aware that they both must have the same type of parameter in order to work. My question is:
Is there a way, or workaround, to this issue?
In my project, I want to connect a simple valuechanged signal to a a slot that receives 3 QWidet parameters.
This is the code in question://OperatorLogged is a valuechanged signal, nothing weird. connect(login, SIGNAL(operatorLogged(int)), this, SLOT(createOperatorInterface(QWidget*, QWidget*, QWidget*))); //createOperatorInterface takes the QWidget arguments and adds them to "this" stacked layout. "This" being the main widget, by the way.I would also like to know if using the main.cpp is the best practice, as I was taught in OOP, to work with my code. The whole issue comes from me trying to work in the main.cpp like this:
#include "mainwidget.h" #include "qlogin.h" #include "qdispense.h" #include "qdispensedisplay.h" #include "qresult.h" #include <QApplication> #include <QCalendarWidget> int main(int argc, char *argv[]) { QApplication Skylord(argc, argv); mainWidget mwMainWidget; mwMainWidget.show(); QLogin *loginWidget = new QLogin; QDispense *dispenseWidget = new QDispense; QDispenseDisplay *dispenseDisplayWidget = new QDispenseDisplay; QResult *resultWidget = new QResult; mwMainWidget.createLogin(loginWidget); return Skylord.exec(); }Thanks in advance.
-
Hi,
Short answer: no
The slot signature must either have the same number or less parameters than the signal and the type must be the same.