QWebView blank screen
- 
It is in my mainwindow.cpp in the function after setupUI @nicholaslee Can you show the code? 
 Also, you said it works if you press a buttons: do you execute exactly the same line when the button is pressed?
- 
#include "mainwindow.h" #include "ui_mainwindow.h" #include <QString> #include <QWebView> #include <QUrl> #include <QDesktopServices> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QString link = "https://nusmods.com/timetable/sem-1"; ui->webView->load(QUrl(link)); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_pushButton_clicked() { QString link = "https://nusmods.com/timetable/sem-1"; QDesktopServices::openUrl(QUrl(link)); }Yes, its the same. All other websites work for webview 
- 
#include "mainwindow.h" #include "ui_mainwindow.h" #include <QString> #include <QWebView> #include <QUrl> #include <QDesktopServices> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QString link = "https://nusmods.com/timetable/sem-1"; ui->webView->load(QUrl(link)); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_pushButton_clicked() { QString link = "https://nusmods.com/timetable/sem-1"; QDesktopServices::openUrl(QUrl(link)); }Yes, its the same. All other websites work for webview @nicholaslee OK, you're loading inside MainWindow constructor - I'm not sure this is the problem as MainWindow is being constructed at that time. You can try to use http://doc.qt.io/qt-5/qtimer.html#singleShot-4 to delay the loading a bit. 
- 
#include "mainwindow.h" #include "ui_mainwindow.h" #include <QString> #include <QWebView> #include <QUrl> #include <QDesktopServices> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QString link = "https://nusmods.com/timetable/sem-1"; ui->webView->load(QUrl(link)); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_pushButton_clicked() { QString link = "https://nusmods.com/timetable/sem-1"; QDesktopServices::openUrl(QUrl(link)); }Yes, its the same. All other websites work for webview @nicholaslee 
 I don't know but: loadhttps://nusmods.com/timetable/sem-1into a web browser and look at the source. The page generated does not contain literal HTML for the view; it's all generated in JavaScript. Is this the root of the problem?
- 
@JonB Yes, I think so, im not totally sure how webview works. How would I load the page if its generated in JavaScript? 
- 
@JonB Yes, I think so, im not totally sure how webview works. How would I load the page if its generated in JavaScript? @nicholaslee Didn't you say that same page is loading fine when you press the button? 
- 
@jsulm yes the button will open the browser and navigate to the URL. But webview is just displaying a blank screen. Is there anyway to view it? 
- 
@jsulm yes the button will open the browser and navigate to the URL. But webview is just displaying a blank screen. Is there anyway to view it? @nicholaslee 
 Put in a slot for http://doc.qt.io/archives/qt-4.8/qwebview.html#loadFinished. Check you do get there, and the value ofok.
- 
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QString link = "https://nusmods.com/timetable/sem-1"; ui->webView->load(QUrl(link)); void QWebView::loadFinished(bool ok); }@JonB sorry im still new to slots, do I just put it in like this? It's giving me an error "invalid use of qualified-name 'QWebView::loadFinished" 
- 
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QString link = "https://nusmods.com/timetable/sem-1"; ui->webView->load(QUrl(link)); void QWebView::loadFinished(bool ok); }@JonB sorry im still new to slots, do I just put it in like this? It's giving me an error "invalid use of qualified-name 'QWebView::loadFinished" @nicholaslee said in QWebView blank screen: void QWebView::loadFinished(bool ok); This declares a function! 
 Please read http://doc.qt.io/qt-5/signalsandslots.html
 You need to doMainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QString link = "https://nusmods.com/timetable/sem-1"; ui->webView->load(QUrl(link)); connect(ui->webView, &QWebView::loadFinished, this, &MainWindow::handleLoadFinished); } void MainWindow::handleLoadFinished(bool ok) { ... }
- 
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QString link = "https://nusmods.com/timetable/sem-1"; ui->webView->load(QUrl(link)); connect(ui->webView, &QWebView::loadFinished, this, &MainWindow::handleLoadFinished); } void MainWindow::handleLoadFinished(bool ok){ qDebug() << QString("Loaded"); }@jsulm @JonB 
 Ive put in a slot and yes it prints out loaded but the webview is not showing anything. Btw thanks for the help!
- 
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QString link = "https://nusmods.com/timetable/sem-1"; ui->webView->load(QUrl(link)); connect(ui->webView, &QWebView::loadFinished, this, &MainWindow::handleLoadFinished); } void MainWindow::handleLoadFinished(bool ok){ qDebug() << QString("Loaded"); }@jsulm @JonB 
 Ive put in a slot and yes it prints out loaded but the webview is not showing anything. Btw thanks for the help!@nicholaslee 
 You need to addqDebug() << ok;there, we need to know what valueokis being passed as.
- 
The value is passed as a 'true' 
- 
The value is passed as a 'true' @nicholaslee 
 Then, fortunately or unfortunately, we've sent you down a wild goose chase, insofar asQWebViewconfirms that it has successfully completed loading the content. But it's good to know!Then I can only guess/suggest as per earlier that (assuming you say it is not a httpsor redirection issue) the web kit is having problems with the JavaScript content? Check the actual content received in theQWebPage/QWebFrameto verify it's what you see in a working browser, and see if there are any signals received indicating it's having problems with the content?
- 
@nicholaslee, you apparently solved your problem (since this is labelled "SOLVED"), but I cannot see what you had to do, if anything, to solve it. Would you mind sharing your findings, if any? (Yes, I am having the same problem with a JavaScript-generated page. I have yet to fully investigate the issue though.) 
 

