QWebEngine on Ubuntu server
-
wrote on 17 Feb 2021, 11:45 last edited by Devoo
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(); }
-
wrote on 17 Feb 2021, 12:02 last edited by eyllanesc
Install and launch the application using xvfb:
sudo apt-get install xvfb xvfb-run ./your_executable
-
@Devoo said in QWebEngine on Ubuntu server:
(without graphical GUI).
Why do you use QApplication then?
-
@Devoo said in QWebEngine on Ubuntu server:
(without graphical GUI).
Why do you use QApplication then?
wrote on 17 Feb 2021, 12:19 last edited by Devoo@eyllanesc It works as expected, thanks!
@Christian-Ehrlicher What should I use? -
@eyllanesc It works as expected, thanks!
@Christian-Ehrlicher What should I use?@Devoo said in QWebEngine on Ubuntu server:
What should I use?
-
wrote on 17 Feb 2021, 12:30 last edited by
Unfortunatelly QWidget cannot be run without QApplication.
Is there any other way to get HTML code using QCoreApplication? -
@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?
-
wrote on 17 Feb 2021, 12:34 last edited by Devoo
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.
1/8