Error: there is no corresponding function to call

I get this error:

main.cpp:31: error: no matching function for call to 'QWebFrame::addToJavaScriptWindowObject(QString, Eh*&)' candidates are: void QWebFrame::addToJavaScriptWindowObject(const QString&, QObject*) 

This is the source code:

 #include <string> #include <QtGui/QApplication> #include <QWebFrame> #include <QWebView> #include <QGraphicsWebView> #include <QWebPage> #include "html5applicationviewer.h" class Eh { int lol() { return 666; } }; int main(int argc, char *argv[]) { QApplication app(argc, argv); Html5ApplicationViewer viewer; viewer.setOrientation(Html5ApplicationViewer::ScreenOrientationAuto); viewer.showExpanded(); viewer.loadFile(QLatin1String("html/index.html")); QWebPage *page = viewer.webView()->page(); QWebFrame *frame = page->mainFrame(); Eh *s = new Eh(); frame->addToJavaScriptWindowObject(QString("test"), s); return app.exec(); } 

I tried to give a new instance of the class Eh and Eh . In both cases, it fails. Also I cannot give a non pointer, since new returns a pointer.

My question is: why is it Eh*& and not Eh* ?

0
source share
1 answer

addToJavaScriptWindowObject accepts a QObject* as the second parameter. Therefore, you need Eh inherit from QObject .

Try something like this:

 class Eh : public QObject { Q_OBJECT public: Eh(QObject *parent = 0) : QObject(parent) { } int lol() { return 666; } }; 
+1
source

All Articles