B
B
Boris the Animal2016-08-16 23:09:09
Programming
Boris the Animal, 2016-08-16 23:09:09

C++ Qt QWebEngineView. How to open Popup window?

I don’t even need to open a link in a new window, I need to follow it in the same window. It's just that links that open in the browser in a new window in a Qt application do not open at all.

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtWebEngineWidgets/QWebEngineView>
#include <qgridlayout.h>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QWebEngineView* webView = new QWebEngineView();
    QGridLayout* layout = new QGridLayout;
    layout->addWidget(webView);
    layout->setAlignment(webView, Qt::AlignCenter);
    webView->setLayout(layout);
    webView->setUrl(QUrl("http://www.google.com/"));
    MainWindow::setCentralWidget(webView);
}

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

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets webenginewidgets

TARGET = CefBrowserExample
TEMPLATE = app


SOURCES += main.cpp\
        mainwindow.cpp

HEADERS  += mainwindow.h

FORMS    += mainwindow.ui

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question