Fullscreen QMainWindow, QGLWidget issue on OSX
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:
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);
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.
Code:
<?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>
Re: Fullscreen QMainWindow, QGLWidget issue on OSX
What is "this" in your code?
The widget taht you add as the central widget?
Cheers,
_
Re: Fullscreen QMainWindow, QGLWidget issue on OSX
Sorry, forgot to mention "this" is the QMainWindow "QtSystem_GameWindow" in the .ui file.
Re: Fullscreen QMainWindow, QGLWidget issue on OSX
But a main window already has a layout.
Which of the main window elements do you currently need?
toolbars? statusbar?
Cheers,
_
Re: Fullscreen QMainWindow, QGLWidget issue on OSX
Quote:
Originally Posted by
anda_skoa
But a main window already has a layout.
Which of the main window elements do you currently need?
toolbars? statusbar?
Cheers,
_
None, just a QGLWidget added to the main window.
Re: Fullscreen QMainWindow, QGLWidget issue on OSX
Then the question becomes: why use a QMainWindow at all?
Why not just have the GL widget as the window itself?
Cheers,
_
Re: Fullscreen QMainWindow, QGLWidget issue on OSX
Quote:
Originally Posted by
anda_skoa
Then the question becomes: why use a QMainWindow at all?
Why not just have the GL widget as the window itself?
Cheers,
_
It's based on the Qt Widgets Application template in the Qt Creator.
Re: Fullscreen QMainWindow, QGLWidget issue on OSX
Ok, so if I understand you correctly, there is no reason to use the QMainWindow.
In which case just remove it and use your widget as the window.
Cheers,
_
Re: Fullscreen QMainWindow, QGLWidget issue on OSX
Quote:
Originally Posted by
anda_skoa
Ok, so if I understand you correctly, there is no reason to use the QMainWindow.
In which case just remove it and use your widget as the window.
Cheers,
_
Thanks, just wonder if there is a way to make QGLWidget have a different framebuffer size from its actual size?
Re: Fullscreen QMainWindow, QGLWidget issue on OSX
No idea sorry.
Btw, I think the more current OpenGL widget is QOpenGLWidget, QGLWidget is deprecated
Cheers,
_
Re: Fullscreen QMainWindow, QGLWidget issue on OSX
Thanks.
My final solution is to scale the offscreen buffer to fill the widget myself.