Results 1 to 11 of 11

Thread: Fullscreen QMainWindow, QGLWidget issue on OSX

Threaded View

Previous Post Previous Post   Next Post Next Post
  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.

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.