Is there a QtQuick equivalent to the C++ QWebFrame::toPlainText() method?
I am able to connect and display a URL page that is plain text using a QML WebView element but I have not found a way to get that content into a string variable. There is no available method or function of the WebView element that will return the text of the content as plain text.
I considered using document.getElementById in a Javascript function but a text document does not have HTML elements necessarily.
I need to get whatever the text is – whether it is HTML, Javascript, or plain text. Can anyone help?
OK since I posted this I have tried several things – none of which even come close. However I did find a post on the forum which I think may be the solution (http://wiki.forum.nokia.com/index.ph...thods_from_QML).
I have constructed a C++ header in this manner:
And additions to my QML project like this:Code:#ifndef WWVSOURCE_H #define WWVSOURCE_H #include <QtCore/QUrl> #include <QtCore/QObject> #include <QtCore/QString> #include <QtCore/QStringList> #include <QtGui/QWidget> #include <QtWebKit/QWebView> #include <QtWebKit/QWebFrame> class URLSource : public QObject { Q_OBJECT public: URLSource(QObject *parent = 0) : QObject(parent) { } Q_INVOKABLE void getURL(const QString &intext) { QWebView *webWWV = new QWebView; webWWV->setUrl(QUrl(intext)); QWebFrame *mainFrame = webWWV->page()->mainFrame(); instr = mainFrame->toPlainText(); } Q_INVOKABLE int getValue() { . . . ; return s; }
The only problem is that there is undefined reference errors in the compile that I am unable to resolve. The output is :Code:function updateUI() { URLSource.getURL(QString("http://www.mysite/afile.txt")); myobject.invalue = URLSource.getValue(); } Component.onCompleted: { // collect text and parse values to plug into meters updateUI(); }
debug/moc_wwvsource.o:moc_wwvsource.cpp:(.text$_ZN9WWVSource6getURLERK7QString[WWVSource::getURL(QString const&)]+0×25): undefined reference to `_imp___ZN8QWebViewC1EP7QWidget’
debug/moc_wwvsource.o:moc_wwvsource.cpp:(.text$_ZN9WWVSource6getURLERK7QString[WWVSource::getURL(QString const&)]+0×50): undefined reference to `_imp___ZN8QWebView6setUrlERK4QUrl’
debug/moc_wwvsource.o:moc_wwvsource.cpp:(.text$_ZN9WWVSource6getURLERK7QString[WWVSource::getURL(QString const&)]+0×84): undefined reference to `_imp___ZNK8QWebView4pageEv’
debug/moc_wwvsource.o:moc_wwvsource.cpp:(.text$_ZN9WWVSource6getURLERK7QString[WWVSource::getURL(QString const&)]+0×8e): undefined reference to `_imp___ZNK8QWebPage9mainFrameEv’
debug/moc_wwvsource.o:moc_wwvsource.cpp:(.text$_ZN9WWVSource6getURLERK7QString[WWVSource::getURL(QString const&)]+0xa5): undefined reference to `_imp___ZNK9QWebFrame11toPlainTextEv’
collect2: ld returned 1 exit status
I have all the includes for QString, QWebView, QWebFrame, QStringList and QUrl in the header. I have cleaned the project and run the QMake several times with no change.
Anyone have a clue?



