我想全屏显示 MainWindow,其内容应根据显示器的大小调整大小:
我的MainWindow.ui
:
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>820</width>
<height>651</height>
</rect>
</property>
<property name="windowTitle">
<string>metaio SDK – Qt Tutorials</string>
</property>
<widget class="QWidget" name="centralwidget">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<layout class="QVBoxLayout" name="mainLayout">
<item alignment="Qt::AlignHCenter">
<widget class="QGraphicsView" name="graphicsView">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>1300</width>
<height>768</height>
</size>
</property>
<property name="resizeAnchor">
<enum>QGraphicsView::NoAnchor</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="buttonLayout">
<item>
<widget class="QPushButton" name="quitTutorialButton">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>« Back</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
<slots>
<slot>on_load_arel()</slot>
<slot>on_load_file()</slot>
<slot>on_close_tab(int)</slot>
<slot>on_save_and_preview()</slot>
<slot>on_preview_channel()</slot>
</slots>
</ui>
我的一些代码MainWindow.cpp
:
...
setupUi(this);
quitTutorialButton->setVisible(false);
QObject::connect(quitTutorialButton, SIGNAL(clicked()), this, SLOT(onQuitTutorialButtonClicked()));
m_pMenu = new Menu(this, this);
// Init the main view for the scene using OpenGL
QGLWidget *glWidget = new QGLWidget(QGLFormat(QGL::SampleBuffers));
m_pGraphicsView = graphicsView;
m_pGraphicsView->setScene(m_pMenu);
m_pGraphicsView->setViewport(glWidget);
m_pGraphicsView->setFrameShape(QFrame::NoFrame);
我的一些代码Menu.cpp
:
m_pWebView = new QGraphicsWebView();
addItem(m_pWebView);
m_pWebView->resize(1300, 768); // dont want this to be static
QObject::connect(m_pWebView, SIGNAL(linkClicked(const QUrl&)), this, SLOT(linkClicked(const QUrl&)));
QTimer::singleShot(20, this, SLOT(loadContent()));
请帮帮我。
编辑:
如果你看到了,我已经以QGraphicsWebView
编程方式添加了。我在我的笔记本上运行这个解决方案,分辨率为 1366 x 768。如果我想使用整个屏幕空间,我必须给我的QGraphicsWebView
(最后添加注释的行)和我QGraphicsView
的位于我的MainWindow.ui
. 我想删除这个静态部分,并使其成为动态的。