Solved Interact with a QQmlApplicationEngine html page.
-
No I forgot this. I will learn it someday, I hope ;)
This webview is becomming a payne, I'm running in one issue after the other.
I just solved the obstacle of closing the webview. I could not use -> exit() or-> close() because those are signals which kill the entire program.
Eventually I learned that I can close the webbrowser with the function ''->deleteLater();" but this works one whole time. The 2nd time I try to open the webbrowser...
The inferior stopped because it received a signal from the operating system. Signal name : SIGSEGV Signal meaning : Segmentation fault
aka crash.
I just want to be able to close the webview just like you do when you press the x. The x is not present on my target device so I need to close the webview in code, I suppose that hiding it underneath my GUI is also an acceptable option. If it is possible that is.
And I still cannot retrieve information out of the html. In the html there is this line
document.title=txtString
The idea
is.... was that when this this rule gets executed, the object name changes and I could get information out of it using the 'objectNameChanged' signal. But it does not seem to work. The html also has it's own exit option but it does not.... exits anything. I added document.close(); to the function in question, but nothing -_-"*Anyways I am open to suggestions.... on Qt's end ofcourse. I have 0,0 experience and knowledge of QML and HTML. And if it would be up to me, I'd be recreating the html in a new Qt window.
-
@bask185 Why not just call hide()?
If you delete it and try to access it later then yes your app will crash as you're trying to access memory you freed before... -
@jsulm said in Interact with a QQmlApplicationEngine html page.:
@bask185 Why not just call hide()?
For once I am on step ahead of you, I think ;) The answer to this question:
/home/user/Dropbox/GUI/GUI_Qt/mainwindow.cpp:151: error: ‘class QQmlApplicationEngine’ has no member named ‘hide’ engine->hide(); ^
The code in the setup is now:
QtWebEngine::initialize(); engine->load(QUrl(QStringLiteral("qrc:/resources/img/webview.qml"))); engine->hide();
@jsulm said in Interact with a QQmlApplicationEngine html page.:
If you delete it and try to access it later then yes your app will crash as you're trying to access memory you freed before...
I figured something like that is why I tried to call ::initialize() again before opening. But I believe 'deleteLater()' deletes the object/member I declared in the header file -->> crash ???
-
@bask185 You cannot call anything on something what was already deleted (deleteLater() deletes the object).
-
@jsulm said in Interact with a QQmlApplicationEngine html page.:
@bask185 You cannot call anything on something what was already deleted (deleteLater() deletes the object).
Yes and I scrolled through the list of functions but I cannot find anything which simply closes the webview window
-
@bask185 QWebView is derived from QWidget and QWidget has hide() method
-
@jsulm said in Interact with a QQmlApplicationEngine html page.:
@bask185 QWebView is derived from QWidget and QWidget has hide() method
But 'member that the thing I am using:
engine = new QQmlApplicationEngine();
is not derived from a QWidget IIRC.
I am using this QML file:
import QtQuick 2.0 import QtQuick.Window 2.0 import QtWebEngine 1.0 Window { width: 1024 height: 750 visible: true WebEngineView { anchors.fill: parent url: "qrc:/resources/img/frmSSPeditor.html" } }
to open the .html
And I did this because this was recommended to me on this here forum.
@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.This + I am not seeing the QWebview widget in Qt creator.
No suggestions for hide, can only find 'handle'. I am telling you hide() isn't there -
@bask185 How did you add that engine to your GUI? Does it have a parent widget? Is it in a layout?
-
@jsulm said in Interact with a QQmlApplicationEngine html page.:
@bask185 How did you add that engine to your GUI? Does it have a parent widget? Is it in a layout?
It has no parent Widgets. In the header file I declare: QQmlApplicationEngine *engine;
In the setup I initialize it:
engine = new QQmlApplicationEngine(); //(this action is called initializing right??)
and I also perform QtWebEngine::initialize();In a function I call: engine->load(QUrl(QStringLiteral("qrc:/resources/img/webview.qml")));
And this line opens a new window with the .qml which opens the .htmlIt is not related to any .ui I also have no controll where the window appears. The reso of the target device is that small that it is just right.
But if you can tell me how to install the QWebview widget in Qt creator, that also works for me.
-
@bask185 said in Interact with a QQmlApplicationEngine html page.:
QWebview
Why don't you use http://doc.qt.io/qt-5/qwebengineview.html? QtWebKit is discontinued QWebEngine should be used instead.
-
@jsulm Becuz I sometimes have no idea of how to get my stuff to work, hence my presence on this here forum ;)
Anways my entire app works like a charm, mostly thanks to your efforts, So thank you!
Even the titleChanged() signal works out of the box, I only have to retrieve some information out of a column somewhere
-
@bask185 Glad to hear it works now :-)