I have a Ui class with a function that i want to call every time i emit a signal from a class lets say test. in the ui function i need to connect my signal and slot but im trying the code from the QT docs and having no luck
signal declaration
signals:
void paint(int x, int y, int id);
signal emit
emit paint(x, y, id)
connection ( m_test
been a class object)
connect(&m_test,SIGNAL(paint(int,int,int)), this, SLOT(uiFunction(int,int,int)));
getting this error
error: C2664: 'QMetaObject::Connection QObject::connect(const QObject *,const char *,const QObject *,const char *,Qt::ConnectionType)' : cannot convert parameter 1 from 'uiFunction *' to 'const QObject *'
but i follwed this QT docs example (counter being the class)
Counter a, b;
QObject::connect(&a, SIGNAL(valueChanged(int)),
&b, SLOT(setValue(int)));
any ideas?
You need your Ui class to inherit from QObject and then add the QOBJECT macro just after the declaration of the class. eg
class Ui : public QObject
{
QOBJECT
signals:
void paint(int x, int y, int id);
private slots:
void UiFunction(int x, int y, int id);
};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.