Results 1 to 11 of 11

Thread: Fullscreen QMainWindow, QGLWidget issue on OSX

  1. #1
    Join Date
    Jun 2016
    Posts
    6
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default 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:
    Qt Code:
    1. QSizePolicy sizePolicy;
    2. sizePolicy.setHorizontalPolicy(QSizePolicy::Expanding);
    3. sizePolicy.setVerticalPolicy(QSizePolicy::Expanding);
    4. m_pGLView->setSizePolicy(sizePolicy);
    5. m_pGLView->resize(size());
    6.  
    7. QLayout* l = new QHBoxLayout(this);
    8. l->setContentsMargins(0,0,0,0);
    9. l->setSizeConstraint(QLayout::SizeConstraint::SetNoConstraint);
    10. setLayout(l);
    11. 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.
    Qt Code:
    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <ui version="4.0">
    3. <class>QtSystem_GameWindow</class>
    4. <widget class="QMainWindow" name="QtSystem_GameWindow">
    5. <property name="geometry">
    6. <rect>
    7. <x>0</x>
    8. <y>0</y>
    9. <width>800</width>
    10. <height>600</height>
    11. </rect>
    12. </property>
    13. <property name="mouseTracking">
    14. <bool>true</bool>
    15. </property>
    16. <property name="windowTitle">
    17. <string>xxxxxx</string>
    18. </property>
    19. <property name="windowIcon">
    20. <iconset resource="xxxxxx.qrc">
    21. <normaloff>:/QtSystem_MainWindow/xxxxxx.ico</normaloff>:/QtSystem_MainWindow/xxxxxx.ico</iconset>
    22. </property>
    23. <widget class="QWidget" name="centralWidget"/>
    24. <widget class="QMenuBar" name="menuBar">
    25. <property name="geometry">
    26. <rect>
    27. <x>0</x>
    28. <y>0</y>
    29. <width>800</width>
    30. <height>21</height>
    31. </rect>
    32. </property>
    33. </widget>
    34. </widget>
    35. <layoutdefault spacing="6" margin="11"/>
    36. <resources>
    37. <include location="xxxxxx.qrc"/>
    38. </resources>
    39. <connections/>
    40. </ui>
    To copy to clipboard, switch view to plain text mode 
    Last edited by yk555; 28th June 2016 at 16:56.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Fullscreen QMainWindow, QGLWidget issue on OSX

    What is "this" in your code?
    The widget taht you add as the central widget?

    Cheers,
    _

  3. #3
    Join Date
    Jun 2016
    Posts
    6
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Re: Fullscreen QMainWindow, QGLWidget issue on OSX

    Sorry, forgot to mention "this" is the QMainWindow "QtSystem_GameWindow" in the .ui file.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default 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,
    _

  5. #5
    Join Date
    Jun 2016
    Posts
    6
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Re: Fullscreen QMainWindow, QGLWidget issue on OSX

    Quote Originally Posted by anda_skoa View Post
    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.

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default 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,
    _

  7. #7
    Join Date
    Jun 2016
    Posts
    6
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Re: Fullscreen QMainWindow, QGLWidget issue on OSX

    Quote Originally Posted by anda_skoa View Post
    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.

  8. #8
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default 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,
    _

  9. #9
    Join Date
    Jun 2016
    Posts
    6
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Re: Fullscreen QMainWindow, QGLWidget issue on OSX

    Quote Originally Posted by anda_skoa View Post
    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?

  10. #10
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Fullscreen QMainWindow, QGLWidget issue on OSX

    No idea sorry.

    Btw, I think the more current OpenGL widget is QOpenGLWidget, QGLWidget is deprecated

    Cheers,
    _

  11. #11
    Join Date
    Jun 2016
    Posts
    6
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Re: Fullscreen QMainWindow, QGLWidget issue on OSX

    Thanks.

    My final solution is to scale the offscreen buffer to fill the widget myself.

Similar Threads

  1. Replies: 20
    Last Post: 13th June 2012, 01:19
  2. Replies: 10
    Last Post: 28th February 2011, 19:53
  3. Strange Behavior with QGLWidget if Fullscreen
    By Barry79 in forum Qt Programming
    Replies: 2
    Last Post: 8th April 2009, 16:35
  4. switch a QWidget inside a QMainWindow to fullscreen
    By koenux in forum Qt Programming
    Replies: 1
    Last Post: 11th January 2009, 21:25
  5. Replies: 1
    Last Post: 21st November 2008, 07:00

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.