Title pretty much says what I need, currently i get 3 messages 2 errors and one warning (I get them on the connect(....) line.
D:\Programming\C++\qtWebkit\webkit.h:27: error: C2061: syntax error: identifier 'page'
D:\Programming\C++\qtWebkit\webkit.h:27: error: C4430: missing type specifier - int assumed. Note: C++ does not support default-int
D:\Programming\C++\qtWebkit\webkit.h:27: warning: C4183: 'connect': missing return type; assumed to be a member function returning 'int'
Code from header.

Qt Code:
  1. #ifndef WEBKIT_H
  2. #define WEBKIT_H
  3. #include <QApplication>
  4. #include <QWebEnginePage>
  5. #include <QEventLoop>
  6. #include <QVariant>
  7. #include <QString>
  8.  
  9. class Webkit
  10. {
  11. public:
  12. void loadUrl(std::string url);
  13. void executeJS(std::string js);
  14. std::string html() { return __html.toStdString(); }
  15. std::string oldHtml() { return __oldHtml.toStdString(); }
  16. std::string jsResult() { return __jsResult.toStdString(); }
  17.  
  18. protected slots:
  19. void _pageLoaded(bool ok);
  20.  
  21. private:
  22. QString __html;
  23. QString __oldHtml = "None";
  24. QString __jsResult = "None";
  25.  
  26. QWebEnginePage page;
  27. connect(page, &QWebEnginePage::loadFinished, this, &Webkit::_pageLoaded);
  28.  
  29. QEventLoop loop;
  30.  
  31. void _jsResult(const QVariant &v);
  32. void _htmlLoaded(QString html);
  33. };
  34.  
  35. #endif // WEBKIT_H
To copy to clipboard, switch view to plain text mode 

Code from cpp

Qt Code:
  1. #include "webkit.h"
  2. #include <QUrl>
  3. #include <QString>
  4. #include <iostream>
  5.  
  6. void Webkit::executeJS(std::string js){
  7. __oldHtml = __html;
  8. page.runJavaScript(QString().fromStdString(js), &Webkit::_jsResult);
  9. loop.exec();
  10. }
  11.  
  12. void Webkit::_jsResult(const QVariant &v){
  13. __jsResult = v.toString();
  14. _pageLoaded(true);
  15. }
  16.  
  17. void Webkit::loadUrl(std::string url) {
  18. page.setUrl(QUrl(QString().fromStdString(url)));
  19. loop.exec();
  20. }
  21.  
  22. void Webkit::_pageLoaded(bool ok){
  23. page.toHtml(&Webkit::_htmlLoaded);
  24. }
  25.  
  26. void Webkit::_htmlLoaded(QString html){
  27. __html = html;
  28. loop.quit();
  29. }
  30.  
  31.  
  32. int main(int argc, char *argv[])
  33. {
  34. QApplication app(argc, argv);
  35.  
  36. Webkit webkit;
  37. webkit.loadUrl("http://google.com");
  38. std::cout << webkit.html() << std::endl;
  39.  
  40. return app.exec();
  41. }
To copy to clipboard, switch view to plain text mode 

Code from .pro

Qt Code:
  1. TEMPLATE = app
  2. QT = core webenginewidgets
  3.  
  4. CONFIG += c++11
  5.  
  6. SOURCES += \
  7. webkit.cpp
  8.  
  9. HEADERS += \
  10. webkit.h
To copy to clipboard, switch view to plain text mode 

Is my connect statement wrong? can't i initlize a QWebEnginePage there? Also tried to make Webkit inherit from QWebEnginePage but still couldn't get it to work.