Reputation: 5204
I'm following the documentation for the WebEngineView
in QT
and I can't get this simple example to work. I've included an image of the layout for context. This all builds without errors, but when the form loads there's nothing there.
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent),
ui(new Ui::MainWindow),
instructionView(new QWebEngineView(this)) {
ui->setupUi(this);
ui->p1Instructions->addWidget(instructionView);
instructionView->load(QUrl("http://qt-project.org/"));
instructionView->show();
}
This is the layout I'm trying to add the WebEngineView
to
This is what I get when I run the program
Upvotes: 1
Views: 831
Reputation: 5204
Turns out it wasn't a WebEngine problem at all, it was a problem of not being aware of some of the 'automagical' things that QT does behind the scenes. I renamed the centralwidget
to root. Renaming it back to centralwidget
fixed the problem.
I could probably also have set the central widget in the constructor like so (note :
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent),
ui(new Ui::MainWindow),
instructionView(new QWebEngineView(this)) {
ui->setupUi(this);
// Set the central widget so QT knows what to display
setCentralWidget(ui->root);
ui->p1Instructions->addWidget(instructionView);
instructionView->load(QUrl("http://qt-project.org/"));
instructionView->show();
}
``
Upvotes: 1