I am using QT5.3 and using following code to add a QGLWidget to a layout of QMainWindow. (tried setCentralWidget as well)
In the QMainWindow("QtSystem_GameWindow" in the .ui file) init code:
sizePolicy.
setHorizontalPolicy(QSizePolicy::Expanding);
m_pGLView->setSizePolicy(sizePolicy);
m_pGLView->resize(size());
l->setContentsMargins(0,0,0,0);
l
->setSizeConstraint
(QLayout::SizeConstraint::SetNoConstraint);
setLayout(l);
l->addWidget(m_pGLView);
QSizePolicy sizePolicy;
sizePolicy.setHorizontalPolicy(QSizePolicy::Expanding);
sizePolicy.setVerticalPolicy(QSizePolicy::Expanding);
m_pGLView->setSizePolicy(sizePolicy);
m_pGLView->resize(size());
QLayout* l = new QHBoxLayout(this);
l->setContentsMargins(0,0,0,0);
l->setSizeConstraint(QLayout::SizeConstraint::SetNoConstraint);
setLayout(l);
l->addWidget(m_pGLView);
To copy to clipboard, switch view to plain text mode
When I am using the native fullscreen button on OSX to make the window(1600x900) go fullscreen, QGLWidget stays 1600x900 and there is black border around the QGLWidget.
Could anyone tell me what should I do to make the QGLWidget to fill the whole screen space and stays at the old size (for example 1600x900)?
Thanks in advance.
Here is the .ui file for the QMainWindow.
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QtSystem_GameWindow</class>
<widget class="QMainWindow" name="QtSystem_GameWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="mouseTracking">
<bool>true</bool>
</property>
<property name="windowTitle">
<string>xxxxxx</string>
</property>
<property name="windowIcon">
<iconset resource="xxxxxx.qrc">
<normaloff>:/QtSystem_MainWindow/xxxxxx.ico</normaloff>:/QtSystem_MainWindow/xxxxxx.ico</iconset>
</property>
<widget class="QWidget" name="centralWidget"/>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>21</height>
</rect>
</property>
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>
<include location="xxxxxx.qrc"/>
</resources>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QtSystem_GameWindow</class>
<widget class="QMainWindow" name="QtSystem_GameWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="mouseTracking">
<bool>true</bool>
</property>
<property name="windowTitle">
<string>xxxxxx</string>
</property>
<property name="windowIcon">
<iconset resource="xxxxxx.qrc">
<normaloff>:/QtSystem_MainWindow/xxxxxx.ico</normaloff>:/QtSystem_MainWindow/xxxxxx.ico</iconset>
</property>
<widget class="QWidget" name="centralWidget"/>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>21</height>
</rect>
</property>
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>
<include location="xxxxxx.qrc"/>
</resources>
<connections/>
</ui>
To copy to clipboard, switch view to plain text mode
Bookmarks