title: QT5 C++ Signal to QML Slot not working
body: <p>I know this question as been multiple times . I have browsed and trying for 5 days to link my C++ signal to a QML slot via Connections in QML . Here is my code at the moment and  I don't understand why I always get :Cannot assign to non-existent property "ondashsetupChanged"
  Please tell me what i am doing wrong ? The complete code is here :
  <a href="https://github.com/BastianGschrey/PowerTune/tree/Simplification" rel="nofollow noreferrer">https://github.com/BastianGschrey/PowerTune/tree/Simplification</a></p>
  
  <p>Here is my code:</p>
  
  <p>my main.cpp :</p>
  
  <pre><code>#include &lt;QApplication&gt;
  #include &lt;QQmlApplicationEngine&gt;
  #include &lt;QQmlContext&gt;
  #include &lt;QtQml&gt;
  #include "connect.h"
  
  
  int main(int argc, char *argv[])
  {
  qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
  QApplication app(argc, argv);
  app.setOrganizationName("Power-Tune");
  app.setOrganizationDomain("power-tune.org");
  app.setApplicationName("PowerTune");
  
  QQmlApplicationEngine engine;
  
  
  qmlRegisterType&lt;Connect&gt;("com.powertune", 1, 0, "ConnectObject");
  engine.rootContext()-&gt;setContextProperty("Connect", new Connect(&amp;engine));
  
  engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
  
  
  return app.exec();
  
  }
  </code></pre>
  
  <p>connect.cpp :</p>
  
  <pre><code>#include "datalogger.h"
  #include "connect.h"
  #include "calculations.h"
  #include "sensors.h"
  #include "AdaptronicSelect.h"
  #include "AdaptronicCAN.h"
  #include "Apexi.h"
  #include "HaltechCAN.h"
  #include "Nissanconsult.h"
  #include "obd.h"
  #include "AdaptronicCAN.h"
  #include "HaltechCAN.h"
  #include "Apexi.h"
  #include "AdaptronicSelect.h"
  #include "dashboard.h"
  #include "serialport.h"
  #include "appsettings.h"
  #include "gopro.h"
  #include "gps.h"
  #include &lt;QDebug&gt;
  #include &lt;QTime&gt;
  #include &lt;QTimer&gt;
  #include &lt;QSerialPort&gt;
  #include &lt;QSerialPortInfo&gt;
  #include &lt;QQmlContext&gt;
  #include &lt;QQmlApplicationEngine&gt;
  #include &lt;QFile&gt;
  #include &lt;QFileInfo&gt;
  #include &lt;QTextStream&gt;
  #include &lt;QByteArrayMatcher&gt;
  #include &lt;QProcess&gt;
  
  int ecu; //0=apex, 1=adaptronic;2= OBD; 3= Dicktator ECU
  int logging; // 0 Logging off , 1 Logging to file
  int connectclicked =0;
  QByteArray checksumhex;
  QByteArray recvchecksumhex;
  
  
  Connect::Connect(QObject *parent) :
  QObject(parent),
  m_serialport(Q_NULLPTR),
  m_dashBoard(Q_NULLPTR),
  m_gopro(Q_NULLPTR),
  m_gps(Q_NULLPTR),
  m_adaptronicselect(Q_NULLPTR),
  m_apexi(Q_NULLPTR),
  m_nissanconsult(Q_NULLPTR),
  m_OBD(Q_NULLPTR),
  m_sensors(Q_NULLPTR),
  m_haltechCANV2(Q_NULLPTR),
  m_adaptronicCAN(Q_NULLPTR),
  m_datalogger(Q_NULLPTR),
  m_calculations(Q_NULLPTR)
  
  {
  getPorts();
  m_dashBoard = new DashBoard(this);
  m_appSettings = new AppSettings(this);
  m_gopro = new GoPro(this);
  m_gps = new GPS(m_dashBoard, this);
  m_adaptronicselect= new AdaptronicSelect(m_dashBoard, this);
  m_apexi= new Apexi(m_dashBoard, this);
  m_nissanconsult = new Nissanconsult(m_dashBoard, this);
  m_OBD = new OBD(m_dashBoard, this);
  m_sensors = new Sensors(m_dashBoard, this);
  m_haltechCANV2 = new HaltechCAN(m_dashBoard, this);
  m_adaptronicCAN = new AdaptronicCAN(m_dashBoard, this);
  m_datalogger = new datalogger(m_dashBoard, this);
  m_calculations = new calculations(m_dashBoard, this);
  
  QQmlApplicationEngine *engine = dynamic_cast&lt;QQmlApplicationEngine*&gt;(   parent );
  if (engine == Q_NULLPTR)
      return;
  engine-&gt;rootContext()-&gt;setContextProperty("Dashboard", m_dashBoard);
  engine-&gt;rootContext()-&gt;setContextProperty("AppSettings", m_appSettings);
  engine-&gt;rootContext()-&gt;setContextProperty("GoPro", m_gopro);
  engine-&gt;rootContext()-&gt;setContextProperty("GPS", m_gps);
  engine-&gt;rootContext()-&gt;setContextProperty("Nissanconsult",m_nissanconsult);
  engine-&gt;rootContext()-&gt;setContextProperty("Sens", m_sensors);
  engine-&gt;rootContext()-&gt;setContextProperty("Logger", m_datalogger);
  }
  
  Connect::~Connect()
  {
  }
  void Connect::checkifraspberrypi()
  {
  QString path = "/sys/class/backlight/rpi_backlight/brightness";
  if (QFileInfo::exists(path))
  {
     m_dashBoard-&gt;setscreen(true);
  }
   else
  {
    m_dashBoard-&gt;setscreen(false);
  }
  }
  
  void Connect::readdashsetup()
  {
  qDebug()&lt;&lt;"c++ file read";
  QString path = "UserDash.txt";// this is just for testing
  QFile inputFile(path);
  if (inputFile.open(QIODevice::ReadOnly))
  {
     QTextStream in(&amp;inputFile);
     while (!in.atEnd())
     {
        QString line = in.readLine();
        QStringList list = line.split(QRegExp("\\,"));
        m_dashBoard-&gt;setdashsetup(list);
        qDebug()&lt;&lt; list;
     }
     inputFile.close();
  }
  
  }
  
  void Connect::setSreenbrightness(const int &amp;brightness)
  {
  
  //This works only on raspberry pi
  QFile f("/sys/class/backlight/rpi_backlight/brightness");
  //f.close();
  f.open(QIODevice::WriteOnly | QIODevice::Truncate);
  QTextStream out(&amp;f);
  out &lt;&lt; brightness;
  //qDebug() &lt;&lt; brightness;
  f.close();
  }
  
  void Connect::setUnits(const int &amp;units)
  {
  switch (units)
  {
  case 0:
      m_dashBoard-&gt;setunits("metric");
      break;
  case 1:
      m_dashBoard-&gt;setunits("imperial");
      break;
  
  default:
      break;
  }
  
  }
  
  void Connect::setWeight(const int &amp;weight)
  {
  m_dashBoard-&gt;setWeight(weight);
  qDebug() &lt;&lt; "weight" &lt;&lt; m_dashBoard-&gt;Weight();
  }
  void Connect::getPorts()
  {
  QStringList PortList;
  foreach(const QSerialPortInfo &amp;info, QSerialPortInfo::availablePorts())
  {
      PortList.append(info.portName());
  }
  setPortsNames(PortList);
  // Check available ports every 1000 ms
  QTimer::singleShot(1000, this, SLOT(getPorts()));
  }
  //function for flushing all Connect buffers
  void Connect::clear() const
  {
    // m_Connectport-&gt;clear();
  }
  
  //function to open Connect port
  void Connect::openConnection(const QString &amp;portName, const int &amp;ecuSelect)
  {
  ecu = ecuSelect;
  
  //Apexi
  if (ecuSelect == 0)
  {
  
      m_apexi-&gt;openConnection(portName);
  
  }
  
  
  //Adaptronic
  if (ecuSelect == 1)
  {
     m_adaptronicselect-&gt;openConnection(portName);
  
  }
  //OBD
  if (ecuSelect == 2)
  {
     m_OBD-&gt;openConnection(portName);
  }
  //Nissan Consult
  if (ecuSelect == 3)
  {
      m_nissanconsult-&gt;LiveReqMsg(1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
      m_nissanconsult-&gt;openConnection(portName);
  
  }
  
  
  //Adaptronic ModularCAN protocol
  if (ecuSelect == 5)
  {
  
      m_adaptronicCAN-&gt;openCAN();
  
  
  }
  //Haltech V2 CAN protocol
  if (ecuSelect == 6)
  {
  
      m_haltechCANV2-&gt;openCAN();
  
  
  }
  }
  void Connect::closeConnection()
  {
  
  
  //Apexi
  if (ecu == 0)
  {
  
      m_apexi-&gt;closeConnection();
  
  }
  
  
  //Adaptronic Select
  if (ecu == 1)
  {
       m_adaptronicselect-&gt;closeConnection();
  
  }
  //OBD
  if (ecu == 2)
  {
     m_OBD-&gt;closeConnection();
  }
  //Nissan Consult
  if (ecu == 3)
  {
      m_nissanconsult-&gt;closeConnection();
  
  }
  
  //Adaptronic ModularCAN protocol
  if (ecu == 5)
  {
  
      m_adaptronicCAN-&gt;closeConnection();
  
  }
  //Haltech V2 CAN protocol
  if (ecu == 6)
  {
  
      m_haltechCANV2-&gt;closeConnection();
  
  }
  }
  
   void Connect::update()
  {
  m_dashBoard-&gt;setSerialStat("Update started");
  QProcess *process = new QProcess(this);
  connect(process , SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(updatefinished(int, QProcess::ExitStatus)));
  process-&gt;start("/home/pi/updatePowerTune.sh");
  process-&gt;waitForFinished(6000000); // 10 minutes time before timeout
  }
  void Connect::updatefinished(int exitCode, QProcess::ExitStatus exitStatus)
  {
  qDebug() &lt;&lt; "code" &lt;&lt;exitCode;
  qDebug() &lt;&lt; "status" &lt;&lt;exitStatus;
  QString fileName = "/home/pi/build/PowertuneQMLGui";
  QFile file(fileName);
  if(QFileInfo::exists(fileName))
  {
      m_dashBoard-&gt;setSerialStat("Update Successful");
      file.close();
  }
  else
  {
      m_dashBoard-&gt;setSerialStat("Update Unsuccessful");
  }
  }
  </code></pre>
  
  <p>connect.h</p>
  
  <pre><code>#ifndef CONNECT_H
  #define CONNECT_H
  
  #include &lt;QtSerialPort/QSerialPort&gt;
  #include &lt;QObject&gt;
  #include &lt;QModbusDataUnit&gt;
  #include &lt;QTimer&gt;
  #include &lt;QProcess&gt;
  #include "calculations.h"
  
  class SerialPort;
  class Sensors;
  class DashBoard;
  class AdaptronicCAN;
  class AdaptronicSelect;
  class Apexi;
  class HaltechCAN;
  class Nissanconsult;
  class OBD;
  class datalogger;
  class calculations;
  class AppSettings;
  class GoPro;
  class GPS;
  class OBD;
  
  class Connect : public QObject
  {
  Q_OBJECT
  Q_PROPERTY(QStringList portsNames READ portsNames WRITE setPortsNames NOTIFY sig_portsNamesChanged)
  
  public:
  ~Connect();
  explicit Connect(QObject *parent = 0);
  Q_INVOKABLE void checkifraspberrypi();
  Q_INVOKABLE void readdashsetup();
  Q_INVOKABLE void setSreenbrightness(const int &amp;brightness);
  Q_INVOKABLE void setUnits(const int &amp;units);
  Q_INVOKABLE void setWeight(const int &amp;weight);
  Q_INVOKABLE void clear() const;
  Q_INVOKABLE void openConnection(const QString &amp;portName, const int &amp;ecuSelect);
  Q_INVOKABLE void closeConnection();
  Q_INVOKABLE void update();
  
  public:
  
  QStringList portsNames() const { return m_portsNames; }
  
  private:
  
  SerialPort *m_serialport;
  DashBoard *m_dashBoard;
  AppSettings *m_appSettings;
  GoPro *m_gopro;
  GPS *m_gps;
  AdaptronicSelect *m_adaptronicselect;
  Apexi *m_apexi;
  Nissanconsult* m_nissanconsult;
  OBD* m_OBD;
  Sensors *m_sensors;
  HaltechCAN *m_haltechCANV2;
  AdaptronicCAN *m_adaptronicCAN;
  datalogger *m_datalogger;
  calculations *m_calculations;
  QStringList m_portsNames;
  QStringList *m_ecuList;
  QThread* CALCThread;
  QProcess process;
  
  
  
  signals:
  void sig_portsNamesChanged(QStringList portsNames);
  
  public slots:
  void updatefinished(int exitCode, QProcess::ExitStatus exitStatus);
  void getPorts();
  void setPortsNames(QStringList portsNames)
  {
      if (m_portsNames == portsNames)
          return;
  
      m_portsNames = portsNames;
      emit sig_portsNamesChanged(portsNames);
  }
  
  
  };
  #endif // CONNECT_H
  </code></pre>
  
  <p>dashbboard.cpp</p>
  
  <pre><code>#include &lt;dashboard.h&gt;
  #include &lt;QStringList&gt;
  #include &lt;QDebug&gt;
  
  DashBoard::DashBoard(QObject *parent)
  : QObject(parent)
  {
  }
  void DashBoard::setdashsetup(const QStringList &amp;dashsetup)
  {
  if (m_dashsetup == dashsetup)
      return;
  m_dashsetup = dashsetup;
  emit dashsetupChanged(dashsetup);
  }
  //User Dashboard Stringlist
  QStringList DashBoard::dashsetup() const { return m_dashsetup; }
  </code></pre>
  
  <p>dashboard.h</p>
  
  <pre><code>#ifndef DASHBOARD_H
  #define DASHBOARD_H
  
  #include &lt;QStringList&gt;
  #include &lt;QObject&gt;
  
  class DashBoard : public QObject
  {
  Q_OBJECT
  
  
  //User Dashboard Stringlist dashsetup
  
  Q_PROPERTY(QStringList dashsetup READ dashsetup WRITE setdashsetup NOTIFY dashsetupChanged)
  
  public:
  DashBoard(QObject *parent = 0);
  
   //User Dashboard Stringlist
  
   QStringList dashsetup() const;
  
  signals:
  QStringList m_dashsetup;
  };
  
  #endif // DASHBOARD_H
  </code></pre>
  
  <p>main.qml:</p>
  
  <pre><code>import QtQuick 2.8
  import QtQuick.Controls 2.1
  import QtQuick.Layouts 1.1
  import com.powertune 1.0
  
  ApplicationWindow {
  
  
  visible: true
  width: 800
  height: 480
  minimumWidth: 800
  minimumHeight: 480
  title: qsTr("PowerTune ") + Dashboard.Platform + " Beta 24"
  // visibility: "FullScreen"
  color: "black"
  
  Connections{
  target: Dashboard
  ondashsetupChanged: console.log("Dashboard has changed")
  }
  
  Item {
      id: name
      Component.onCompleted: Connect.checkifraspberrypi()
  }
  SwipeView {
      id: view
  
      currentIndex: 0
      anchors.fill: parent
  
      Loader {
  
          id: firstPageLoader
          source: ""
  
      }
  
      Loader {
          id: secondPageLoader
          source: ""
  
      }
      Loader {
          id: thirdPageLoader
          source: ""
  
       }
  
      Loader {
          id: fourthPageLoader
          source: ""
      }
  
      Item {
          id:lastPage
          SerialSettings{}
      }
  }
  
  
  
  PageIndicator {
      id: indicator
  
      count: view.count
      currentIndex: view.currentIndex
  
      anchors.bottom: view.bottom
      anchors.horizontalCenter: parent.horizontalCenter
  }
  }
  </code></pre>