0
votes

i am struggling a bit with my project and the thing that is making me really annoyed right now is QWebview. So i tried to create a new project. In this new project all have is blank Qt widget application with one webview added from Qt Designer.

The problem is as the header says, my webview is not willing to load any webpage i have tried all sorts of possibilities for webpage: http://google.com https://google.com http://www.google.com https://www.google.com www.google.com

None of which works, all just give blank page as if about:blank

this is the code

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtWebKitWidgets/QWebView>
#include <QUrl>
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    ui->webView->load(QUrl("http://www.google.com"));
}

MainWindow::~MainWindow()
{
    delete ui;
}

I didn't forgot to put QT+= webkitwidgets in pro, also included all libs.

Any suggestions?

1
It seems there is nothing wrong with your code. Try to check loadFinished() or try add ui->webView->show() after load() - demonplus
Adding show doesnt add anything and loadfinished() seems to work fine just bool ok of it is false which suggests the load was finished with errors. Any suggestions? Sorry i am kinda bad when it comes to troubleshooting errors in qt ( been workign with it lik 2 weeks) - Alexander Baťka
This seems to directly work for me too, so I'm not sure if there's anything wrong with your code. The size of your webView Widget is large enough? Also, did you try other webpages? - Tim Smit
what exactly qt version and platform are you using? - demonplus
I am suing qt 5.5 with VC++ 12 compiler.Yes i put google there just as an example of all the possible combinations of pages i used. I tried also, facebook, yahoo, youtube and microsoft. None has worked. And the webvies is big enough, although it should work also for smaller once, it shioul just scale into it. - Alexander Baťka

1 Answers

0
votes

Oukey i resolved my problem.

Still dont know what was wrong with QWebView instead i used QWebEngineView and that worked like a charm.

Maybe since its chromium that is the reason.

Thanks all for their inputs.