Solved Trying to render a website on my program..
-
Hi !
I want to show a website inside a QHBoxLayout
reservas.pro
QT += core gui sql webenginewprincipal.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. -
@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
-
Thanks for answering...
When i include that module i receive the error that the module is unknown... -
@U7Development Which Qt version did you install and how?
-
@jsulm i have installed 5.14 on Debian
Selected then the following items before installing:
Qt creator
Gcc kit
Sources
Qt webEngine -
@U7Development Then your users could simply do the same.
-
@jsulm excuse me, i did not get that..
-
@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. -
@jsulm oh ok..
Yes, webengine is checked before installing it...
Im going to make a Windows test .. -
-
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)
-
Installed QtWebEngine from installer
-
on the .pro file, add webenginewidgets:
QT += core gui sql webenginewidgets (was my case) -
on wprincipal.ui added a Widget type container to hold the website (i named it wdgtWeb)
-
added pointer of type QWebEngineView to window widget header (wprincipal.h) in my case :
class QWebEngineView (forwarding)
private:
QWebEngineView* minsal_web {nullptr};-
#include <QWebEngineView> on wprincipal.cpp
-
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. -