c++ - TypeError: Result of expression 'dbMasterObject.updateIntoTestResult' [undefined] is not a function -


i doing database operations in project. have file 'databasemaster',which has function updateintotestresult(). have created dbmasterobject setting context this

qml->setcontextproperty("dbmasterobject", dbmasterobject);

but when try call updateintotestresult() method in main.qml,i getting error

typeerror: result of expression 'dbmasterobject.updateintotestresult' [undefined] not function

databasemaster.hpp

  class databasemaster : public qobject { public:       q_object public:     void updateintotestresult(int id, int result);  }; 

databasemaster.cpp

void databasemaster::updateintotestresult(int id, int result) {  qsqldatabase database = qsqldatabase::database();  qsqlquery query(database);  query.prepare("update "+test_result_master+" set "+result+" = :"+result+" "+test_id+"= :"+test_id+";");  query.bindvalue(":"+result, result); query.bindvalue(":"+test_id, id);  query.exec(); 

calling in main.qml

dbmasterobject.updateintotestresult(microphone_id, test_state_pass) 

please me out, why getting error whereas have declared method correctly.

thanks in advance..!!

updateintotestresult not known qml system because it's not slot or q_invokable.

simple fix - insert q_invokable:

class databasemaster : public qobject { public:     q_object public:     q_invokable void updateintotestresult(int id, int result); }; 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -