Qt 小部件全屏边距
Qt Widgets FullScreen Margin
我想创建一个可以全屏加载 google 的程序,所以我使用 w.showFullScreen();
实现了全屏打开我的 qt 程序并且它运行完美,但是当我添加 QWebView
并将其设置为 centralWidget
,如下所示:
但是当我 运行 程序时,我在 window 的两侧得到了一些边距,换句话说 QWebView
与 window 也就是说,它看起来像这样:
我不认为我的代码有误,但它在这里
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;
}
谢谢。
您的中央小部件有布局。 QtDesigner 中可能有 layoutLeftMargin、layoutRightMargin、layoutTopMargin、layoutBottomMargin 以及除 0 以外的其他值,单击中央小部件,然后在属性的下方将边距设置为 0。
我想创建一个可以全屏加载 google 的程序,所以我使用 w.showFullScreen();
实现了全屏打开我的 qt 程序并且它运行完美,但是当我添加 QWebView
并将其设置为 centralWidget
,如下所示:
但是当我 运行 程序时,我在 window 的两侧得到了一些边距,换句话说 QWebView
与 window 也就是说,它看起来像这样:
我不认为我的代码有误,但它在这里 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;
}
谢谢。
您的中央小部件有布局。 QtDesigner 中可能有 layoutLeftMargin、layoutRightMargin、layoutTopMargin、layoutBottomMargin 以及除 0 以外的其他值,单击中央小部件,然后在属性的下方将边距设置为 0。