Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. QWebEngine on Ubuntu server
Forum Updated to NodeBB v4.3 + New Features

QWebEngine on Ubuntu server

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
8 Posts 4 Posters 771 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Devoo
    wrote on 17 Feb 2021, 11:45 last edited by Devoo
    #1

    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 files

    1. webengine-test.pro:
    TEMPLATE = app
    QT += webenginewidgets
    SOURCES += sources/main.cpp
    
    1. 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();
    }
    
    1 Reply Last reply
    0
    • E Offline
      E Offline
      eyllanesc
      wrote on 17 Feb 2021, 12:02 last edited by eyllanesc
      #2

      Install and launch the application using xvfb:

      sudo apt-get install xvfb
      xvfb-run ./your_executable
      

      If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

      1 Reply Last reply
      2
      • C Offline
        C Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on 17 Feb 2021, 12:04 last edited by
        #3

        @Devoo said in QWebEngine on Ubuntu server:

        (without graphical GUI).

        Why do you use QApplication then?

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        D 1 Reply Last reply 17 Feb 2021, 12:19
        2
        • C Christian Ehrlicher
          17 Feb 2021, 12:04

          @Devoo said in QWebEngine on Ubuntu server:

          (without graphical GUI).

          Why do you use QApplication then?

          D Offline
          D Offline
          Devoo
          wrote on 17 Feb 2021, 12:19 last edited by Devoo
          #4

          @eyllanesc It works as expected, thanks!
          @Christian-Ehrlicher What should I use?

          J 1 Reply Last reply 17 Feb 2021, 12:21
          0
          • D Devoo
            17 Feb 2021, 12:19

            @eyllanesc It works as expected, thanks!
            @Christian-Ehrlicher What should I use?

            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 17 Feb 2021, 12:21 last edited by
            #5

            @Devoo said in QWebEngine on Ubuntu server:

            What should I use?

            https://doc.qt.io/qt-5/qcoreapplication.html

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            1
            • D Offline
              D Offline
              Devoo
              wrote on 17 Feb 2021, 12:30 last edited by
              #6

              Unfortunatelly QWidget cannot be run without QApplication.
              Is there any other way to get HTML code using QCoreApplication?

              1 Reply Last reply
              0
              • C Offline
                C Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on 17 Feb 2021, 12:31 last edited by
                #7

                @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?

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  Devoo
                  wrote on 17 Feb 2021, 12:34 last edited by Devoo
                  #8

                  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 Reply Last reply
                  0

                  1/8

                  17 Feb 2021, 11:45

                  • Login

                  • Login or register to search.
                  1 out of 8
                  • First post
                    1/8
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved