Search code examples
c++qtfullscreenqwidgetqwebview

Qt Widgets FullScreen Margin


I want to create a program that loads google in literally full screen, so I achieved opening my qt program in full screen using w.showFullScreen(); and it works perfectly, however when I add the QWebView and set it to centralWidget like this:

enter image description here

but when I run the program, I get some margins on the sides of the window, in other words the QWebView isn't literally in fullScreen harmoniously with the window which is, it looks like this:

enter image description here

I don't think my code is mistaken but here it is untitled.pro:

#-------------------------------------------------
#
# Project created by QtCreator 2015-02-07T21:25:42
#
#-------------------------------------------------

CONFIG   += release

QT       += core gui
QT       += webkitwidgets

main.cpp

w.showFullScreen();

mainwindow.cpp

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtWebKitWidgets>

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;
}

Thank you.


Solution

  • Your central widget have a layout. It's possible that you have layoutLeftMargin, layoutRightMargin, layoutTopMargin, layoutBottomMargin with others values than 0 got in you QtDesigner click on your central widget and at the down of you properties set the margins to 0.