我想创建一个程序来全屏加载 google,所以我使用 w.showFullScreen();
实现了全屏打开我的 qt 程序,它工作得很好,但是当我添加QWebView
并将其设置为 centralWidget
,如下所示:
但是当我运行该程序时,我在窗口的两侧得到了一些边距,换句话说,QWebView
并不是字面上与窗口和谐地全屏显示,它看起来像这样:
我不认为我的代码有误,但它在这里 无标题.pro:
#-------------------------------------------------
#
# Project created by QtCreator 2015-02-07T21:25:42
#
#-------------------------------------------------
CONFIG += release
QT += core gui
QT += webkitwidgets
主要.cpp
w.showFullScreen();
主窗口.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。
关于c++ - Qt 小部件全屏边距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28385675/