Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. Trying to render a website on my program..
Forum Updated to NodeBB v4.3 + New Features

Trying to render a website on my program..

Scheduled Pinned Locked Moved Solved QtWebEngine
11 Posts 2 Posters 1.7k 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.
  • U U7Development

    Hi !

    I want to show a website inside a QHBoxLayout

    reservas.pro
    QT += core gui sql webengine

    wprincipal.h

    #ifndef WPRINCIPAL_H
    #define WPRINCIPAL_H
    
    #include <QMainWindow>
    
    QT_BEGIN_NAMESPACE
    namespace Ui { class wprincipal; }
    QT_END_NAMESPACE
    
    class QWebEngineView;
    
    
    class wprincipal : public QMainWindow{
        Q_OBJECT
    public:
        wprincipal(QWidget *parent = nullptr);
        ~wprincipal();
    
    private:
        Ui::wprincipal *ui;
        QWebEngineView* web;
    
    };
    #endif // WPRINCIPAL_H
    
    

    wprincipal.cpp

    #include "wprincipal.h"
    #include "ui_wprincipal.h"
    #include <QtWebEngineWidgets/QtWebEngineWidgets>
    #include <QUrl>
    
    wprincipal::wprincipal(QWidget *parent) : QMainWindow(parent), ui(new Ui::wprincipal){
        ui->setupUi(this);
    
        web = new QWebEngineView;     //** got error
        ui->hlWeb->addWidget(web);
        web->page()->load(QUrl("http://www.google.com"));
    

    **Got error:
    undefined reference to `QWebEngineView::QWebEngineView(QWidget
    )'

    Do I need to do something else?...
    Thanks in advance.

    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #2

    @U7Development said in Trying to render a website on my program..:

    QT += core gui sql webengine

    As shown in the documentation (https://doc.qt.io/qt-5/qwebengineview.html) it needs to be

    QT += core gui sql webenginewidgets
    

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

    1 Reply Last reply
    1
    • U Offline
      U Offline
      U7Development
      wrote on last edited by
      #3

      Thanks for answering...
      When i include that module i receive the error that the module is unknown...

      jsulmJ 1 Reply Last reply
      0
      • U U7Development

        Thanks for answering...
        When i include that module i receive the error that the module is unknown...

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #4

        @U7Development Which Qt version did you install and how?

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

        U 1 Reply Last reply
        0
        • jsulmJ jsulm

          @U7Development Which Qt version did you install and how?

          U Offline
          U Offline
          U7Development
          wrote on last edited by
          #5

          @jsulm i have installed 5.14 on Debian
          Selected then the following items before installing:
          Qt creator
          Gcc kit
          Sources
          Qt webEngine

          jsulmJ 1 Reply Last reply
          0
          • U U7Development

            @jsulm i have installed 5.14 on Debian
            Selected then the following items before installing:
            Qt creator
            Gcc kit
            Sources
            Qt webEngine

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #6

            @U7Development Then your users could simply do the same.

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

            U 1 Reply Last reply
            0
            • jsulmJ jsulm

              @U7Development Then your users could simply do the same.

              U Offline
              U Offline
              U7Development
              wrote on last edited by
              #7

              @jsulm excuse me, i did not get that..

              jsulmJ 1 Reply Last reply
              0
              • U U7Development

                @jsulm excuse me, i did not get that..

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #8

                @U7Development I think my last reply was meant for another thread, sorry :-)
                Did you install Web Engine? It is not installed by default when using online installer. Start Qt Maintenance Tool and select Web Engine.

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

                U 2 Replies Last reply
                1
                • jsulmJ jsulm

                  @U7Development I think my last reply was meant for another thread, sorry :-)
                  Did you install Web Engine? It is not installed by default when using online installer. Start Qt Maintenance Tool and select Web Engine.

                  U Offline
                  U Offline
                  U7Development
                  wrote on last edited by
                  #9

                  @jsulm oh ok..

                  Yes, webengine is checked before installing it...
                  Im going to make a Windows test ..

                  1 Reply Last reply
                  0
                  • jsulmJ jsulm

                    @U7Development I think my last reply was meant for another thread, sorry :-)
                    Did you install Web Engine? It is not installed by default when using online installer. Start Qt Maintenance Tool and select Web Engine.

                    U Offline
                    U Offline
                    U7Development
                    wrote on last edited by
                    #10

                    @jsulm as reference i followed this video and did the same (only the first topic of the video)

                    link text

                    1 Reply Last reply
                    0
                    • U U7Development

                      Hi !

                      I want to show a website inside a QHBoxLayout

                      reservas.pro
                      QT += core gui sql webengine

                      wprincipal.h

                      #ifndef WPRINCIPAL_H
                      #define WPRINCIPAL_H
                      
                      #include <QMainWindow>
                      
                      QT_BEGIN_NAMESPACE
                      namespace Ui { class wprincipal; }
                      QT_END_NAMESPACE
                      
                      class QWebEngineView;
                      
                      
                      class wprincipal : public QMainWindow{
                          Q_OBJECT
                      public:
                          wprincipal(QWidget *parent = nullptr);
                          ~wprincipal();
                      
                      private:
                          Ui::wprincipal *ui;
                          QWebEngineView* web;
                      
                      };
                      #endif // WPRINCIPAL_H
                      
                      

                      wprincipal.cpp

                      #include "wprincipal.h"
                      #include "ui_wprincipal.h"
                      #include <QtWebEngineWidgets/QtWebEngineWidgets>
                      #include <QUrl>
                      
                      wprincipal::wprincipal(QWidget *parent) : QMainWindow(parent), ui(new Ui::wprincipal){
                          ui->setupUi(this);
                      
                          web = new QWebEngineView;     //** got error
                          ui->hlWeb->addWidget(web);
                          web->page()->load(QUrl("http://www.google.com"));
                      

                      **Got error:
                      undefined reference to `QWebEngineView::QWebEngineView(QWidget
                      )'

                      Do I need to do something else?...
                      Thanks in advance.

                      U Offline
                      U Offline
                      U7Development
                      wrote on last edited by U7Development
                      #11

                      I have returned here to say that i have solved it...!!
                      Just looked into the built in examples a very basic but working example and works!

                      This is what i did (for someone else that want to make it work)

                      1. Installed QtWebEngine from installer

                      2. on the .pro file, add webenginewidgets:
                        QT += core gui sql webenginewidgets (was my case)

                      3. on wprincipal.ui added a Widget type container to hold the website (i named it wdgtWeb)

                      4. added pointer of type QWebEngineView to window widget header (wprincipal.h) in my case :

                      class QWebEngineView (forwarding)
                      private:
                      QWebEngineView* minsal_web {nullptr};

                      1. #include <QWebEngineView> on wprincipal.cpp

                      2. add these lines in somewhere you initialize your program (or in the constructor):

                      minsal_web = new QWebEngineView;
                      minsal_web->setParent(ui->wdgtWeb);
                      minsal_web->setFixedSize(QSize(1021, 701));
                      minsal_web->setUrl(QUrl(QStringLiteral("https://www.minsal.cl")));
                      minsal_web->show();

                      Point Nº 2 is the same as @jsulm said, for some reason now is getting fine... still don't get why...
                      but for sure, the Point Nº 5 is different than i was writing, so that helped too.

                      1 Reply Last reply
                      0

                      • Login

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