Important: Please read the Qt Code of Conduct -

Full screen QWebEngine without margins?

  • I am trying to get QWebEngine to fill the entire window. Per this answer I am trying to use setContentsMargins(0,0,0,0); with the result below: the QWebEngine loads the page at full window size but then immediately scales down to this:

    enter image description here

    When I use setContentsMargins(1,1,1,1); with the QWebEngine in the layout, it loads correctly, with a 1 px margin. I did a test of just loading the image directly, with no margin and it loaded fine and filled the screen.

    Is this my bug/issue or QWebEngine's?

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include <QtWebEngineWidgets>
    MainWindow::MainWindow(QWidget *parent) :
        ui(new Ui::MainWindow)
        QVBoxLayout *mainLayout = new QVBoxLayout;
    //    // load and show image
    //    inputImg = new QImage(":/images/testScreen.jpg");
    //    imgDisplayLabel = new QLabel("");
    //    imgDisplayLabel->setPixmap(QPixmap::fromImage(*inputImg));
    //    imgDisplayLabel->adjustSize();
    //     mainLayout->addWidget(imgDisplayLabel);
        view = new QWebEngineView(this);
        QUrl url;
        url = QUrl("qrc:/testScreen.html");

Log in to reply