Qt Widgets FullScreen Margin

穿精又带淫゛_ 提交于 2019-12-20 05:47:25

问题


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:

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:

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.


回答1:


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.



来源:https://stackoverflow.com/questions/28385675/qt-widgets-fullscreen-margin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!