Browsers and Java Script.
-
The next step in my HMI project is to implent a browser which can display text using java script and HTML code.
I see (and correct me if I'm wrong) that I can use a QQuickWidget in combination with QML code according to this website
But I also see that I can use a Qt WebKit
What I need to realize looks a bit like this: (I hope these damned screenshots work)
So what is wise for me to do?
-
@mrjj said in Browsers and Java Script.:
@bask185 said in Browsers and Java Script.:
QtWebEngine
You need
QT += webengine
in .pro fileFunny, I recall me saying something about I was not going to forget to include something in .PRO file again -_-"
Anyways, it works :D
Now I have to figure out how to place it precisely and how to interact with it.
-
The next step in my HMI project is to implent a browser which can display text using java script and HTML code.
I see (and correct me if I'm wrong) that I can use a QQuickWidget in combination with QML code according to this website
But I also see that I can use a Qt WebKit
What I need to realize looks a bit like this: (I hope these damned screenshots work)
So what is wise for me to do?
@bask185
QML isn't related to HTML at all. It just uses a JavaScript engine internally.
I can't see your posted images, so it's hard to give an advise.Are you dependent on HTML?
If you need to build a GUI on the device you are better off with QML. -
I might or might not have fixed my screenshots, I believe they work now?Damned photobucket no longer worksAnyways I have a .html file which I need to display. I used a QTextBrowser so far but I have more than just text. QML like you said also does not suffice. So I think I'm gonna try to use a QWebKit browser.
-
Now I used imgur for the screenshots, lets see if that works.
The thing you are looking at is a complex html file which I do need to make it work in my Qt application.
I learned that I need to install the QtWebkit module. I don't have it yet. I tried it using Qt's Maintenance tool but that tool does not work without a commercial license it seems.
I have seen that that there widgets for a webview as well as a module you can use in combination with QML. The latter I tried and gave me the erros: qrc:/resources/img/webview.qml:3:1: module "QtWebKit" is not installed This was how I found out I don't have this module.
Are there other ways in how to install missing modules?
-
Now I used imgur for the screenshots, lets see if that works.
The thing you are looking at is a complex html file which I do need to make it work in my Qt application.
I learned that I need to install the QtWebkit module. I don't have it yet. I tried it using Qt's Maintenance tool but that tool does not work without a commercial license it seems.
I have seen that that there widgets for a webview as well as a module you can use in combination with QML. The latter I tried and gave me the erros: qrc:/resources/img/webview.qml:3:1: module "QtWebKit" is not installed This was how I found out I don't have this module.
Are there other ways in how to install missing modules?
@bask185 said in Browsers and Java Script.:
Qt's Maintenance tool but that tool does not work without a commercial license
This is simply wrong. The maintenance tool works just fine here without commercial license. Why do you think it only works with commercial license?
Actually you should use Qt WebEngine not QtWebKit. -
Now I used imgur for the screenshots, lets see if that works.
The thing you are looking at is a complex html file which I do need to make it work in my Qt application.
I learned that I need to install the QtWebkit module. I don't have it yet. I tried it using Qt's Maintenance tool but that tool does not work without a commercial license it seems.
I have seen that that there widgets for a webview as well as a module you can use in combination with QML. The latter I tried and gave me the erros: qrc:/resources/img/webview.qml:3:1: module "QtWebKit" is not installed This was how I found out I don't have this module.
Are there other ways in how to install missing modules?
@bask185
QtWebkit is deprecated in the meantime and has been replaced by QtWebEngine (based on Chromium).
Try using WebEngineView instead. -
@bask185
QtWebkit is deprecated in the meantime and has been replaced by QtWebEngine (based on Chromium).
Try using WebEngineView instead.@raven-worx said in Browsers and Java Script.:
@bask185
QtWebkit is deprecated in the meantime and has been replaced by QtWebEngine (based on Chromium).
Try using WebEngineView instead.Thank you,
I added to the setup of MainWindow:
QtWebEngine::initialize(); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/webview.qml")));
And I included: #include <QtWebEngine/QtWebEngine>
But Imma getting an error message:
/home/user/Dropbox/GUI/GUI_Qt/mainwindow.cpp:-1: error: undefined reference to `QtWebEngine::initialize()'
-
@raven-worx said in Browsers and Java Script.:
@bask185
QtWebkit is deprecated in the meantime and has been replaced by QtWebEngine (based on Chromium).
Try using WebEngineView instead.Thank you,
I added to the setup of MainWindow:
QtWebEngine::initialize(); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/webview.qml")));
And I included: #include <QtWebEngine/QtWebEngine>
But Imma getting an error message:
/home/user/Dropbox/GUI/GUI_Qt/mainwindow.cpp:-1: error: undefined reference to `QtWebEngine::initialize()'
-
@mrjj said in Browsers and Java Script.:
@bask185 said in Browsers and Java Script.:
QtWebEngine
You need
QT += webengine
in .pro fileFunny, I recall me saying something about I was not going to forget to include something in .PRO file again -_-"
Anyways, it works :D
Now I have to figure out how to place it precisely and how to interact with it.
-
Hey speakin' about placing it. The webview thing behaves very oddly when it comes to opening.
It either opens at startup or it does not open at all, atleast not without closing immediately.
I put these lines in a function which gets called when I push on a button. It opens but it closes immediately.
QtWebEngine::initialize(); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/webview.qml")));
And when I add these lines to the setup, the browser opens without closing. Only at this point I dont want the browser to be visable yet. I need to be able to manually open or close the browser. I tried everything but I cannot get this to work :/
It also appears to be needing a blank QtQuickWidget somewhere
-
Hey speakin' about placing it. The webview thing behaves very oddly when it comes to opening.
It either opens at startup or it does not open at all, atleast not without closing immediately.
I put these lines in a function which gets called when I push on a button. It opens but it closes immediately.
QtWebEngine::initialize(); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/webview.qml")));
And when I add these lines to the setup, the browser opens without closing. Only at this point I dont want the browser to be visable yet. I need to be able to manually open or close the browser. I tried everything but I cannot get this to work :/
It also appears to be needing a blank QtQuickWidget somewhere
@bask185 said in Browsers and Java Script.:
- It opens but it closes immediately.
QtWebEngine::initialize();
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/webview.qml")));You kill it by running out of scope.
As soon as function finishes, the engine variable will die.QQmlApplicationEngine engine; <<< make this a class member