Hi,

Been searching around for an explanation to this problem, but no luck. Any help appreciated

I want to send a signal from my c++ class to a qml function/slot

If I do it without using any parameters it works nicely, like this:
connect(this, SIGNAL(temp()), m_parent, SLOT(settemp()));

But when adding parameters of type int it fails with the "No such slot" error, like this:
connect(this, SIGNAL(valueChanged(int)), m_parent, SLOT(setslider(int)));

Please study the code below and help a Qt newb ...

Qt Code:
  1. //! [imports]
  2. import QtQuick 1.0
  3. import "content"
  4. //! [imports]
  5.  
  6. //! [0]
  7. Rectangle {
  8. color: "#545454"
  9. width: 300; height: 300
  10.  
  11. // Signals
  12. signal sliderX(int X)
  13.  
  14. // Slots
  15. function settemp(){ dial.value = 50; }
  16. function setslider(value){ dial.value = value; }
  17.  
  18. Dial {
  19. id: dial
  20. anchors.centerIn: parent
  21. value: 10
  22. }
  23. }
  24. //! [0]
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. #ifndef MYTEST_H
  2. #define MYTEST_H
  3.  
  4. #include <QObject>
  5.  
  6. class myTest: public QObject
  7. {
  8. Q_OBJECT
  9.  
  10. public:
  11. myTest(QObject *parent) : QObject(parent)
  12. {
  13. m_value = 0;
  14. m_parent = parent;
  15. connect(m_parent, SIGNAL(sliderX(int)), this, SLOT(setValue(int)));
  16.  
  17. connect(this, SIGNAL(temp()), m_parent, SLOT(settemp()));
  18. connect(this, SIGNAL(valueChanged(int)), m_parent, SLOT(setslider(int)));
  19.  
  20. emit temp();
  21. emit valueChanged(100);
  22. }
  23. int value() const { return m_value; }
  24.  
  25. public slots:
  26. void setValue(int value)
  27. {
  28. if (value != m_value)
  29. {
  30. m_value = value;
  31. emit valueChanged(value);
  32. }
  33. }
  34. signals:
  35. void valueChanged(int newValue);
  36. void temp();
  37.  
  38. private:
  39. int m_value;
  40. QObject *m_parent;
  41. };
  42.  
  43. #endif // MYTEST_H
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. #include <QApplication>
  2. #include <QWidget>
  3. #include <QtGui>
  4. #include <QtDeclarative/QDeclarativeView>
  5. #include <QtDeclarative/QDeclarativeContext>
  6. #include "myTest.h"
  7.  
  8.  
  9.  
  10. int main(int argc, char *argv[])
  11. {
  12. QApplication a(argc, argv);
  13.  
  14. QDeclarativeView view;
  15.  
  16. view.setSource(QUrl::fromLocalFile("../test2/qml/dialcontrol.qml"));
  17.  
  18. QObject *object = view.rootObject();
  19.  
  20. QDeclarativeContext *context = view.rootContext();
  21.  
  22. myTest test(object);
  23.  
  24. (*context).setContextProperty("myTest", &test);
  25.  
  26. view.show();
  27.  
  28. return a.exec();
  29. }
To copy to clipboard, switch view to plain text mode