QWebEngine on Ubuntu server
-
Hi,
I want to create some software on Ubuntu Server 18.04 (without graphical GUI).
This software should use QWebEngine to fetch HTML code when some triggers are invoked - JS, AJAX etc.Unfortunatelly I got errors:
QML debugging is enabled. Only use this in a safe environment. qt.qpa.xcb: could not connect to display qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found. This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem. Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb. Aborted (core dumped)
This software was built on the same Ubuntu with GUI and tested on tty.
Any idea how to resolve this issue?
#edit
Project filesTEMPLATE = app QT += webenginewidgets SOURCES += sources/main.cpp
- sources/main.cpp
#include <QtWebEngineWidgets> int main(int argc, char *argv[]) { QApplication app(argc, argv); QWebEngineView *view = new QWebEngineView; QObject::connect(view, &QWebEngineView::loadFinished, [view](bool ok){ view->page()->toHtml ( [](const QString& html) { qDebug() << html; } ); }); view->load(QUrl("http://localhost/jstestengine/")); return app.exec(); }
-
@Devoo said in QWebEngine on Ubuntu server:
(without graphical GUI).
Why do you use QApplication then?
-
@eyllanesc It works as expected, thanks!
@Christian-Ehrlicher What should I use? -
@Devoo said in QWebEngine on Ubuntu server:
What should I use?
-
@Devoo said in QWebEngine on Ubuntu server:
s there any other way to get HTML code
What do you mean with this? Receiving data from an url?
-
I mean, some websites require some JavaScript action, such as:
Hello <div id="name"></div> <script> document.getElementById("name").innerHTML = "John"; </script>
I want to get:
Hello <div id="name">John</div> <script> document.getElementById("name").innerHTML = "John"; </script>
"John" was added.
#edit
Other dynamic content may also appear e.g. using AJAX.