Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QOpenGLWidget doesn't draw OpenGL frame on macOS Mojave until a resize event occurs while built with CMake



  • Greetings:

    I noticed that my QOpenGLWidget-based application (Qt ver. 5.12.0) doesn't display the OpenGL portion of the window until the window is resized on macOS Mojave (ver. 10.14.2) if I build with CMake as opposed to qmake. I observed this issue with Qt's "hellogl2" example as well. Does anyone have any thoughts? I have the "hellogl2" project file below along with what I thought its appropriate CMake counterpart would be (heavily influenced from Qt's CMake Manual). Thank you for your help with this.

    File hellogl2.pro

    HEADERS       = glwidget.h \
                    window.h \
                    mainwindow.h \
                    logo.h
    SOURCES       = glwidget.cpp \
                    main.cpp \
                    window.cpp \
                    mainwindow.cpp \
                    logo.cpp
    
    QT           += widgets
    
    # install
    target.path = $$[QT_INSTALL_EXAMPLES]/opengl/hellogl2
    INSTALLS += target
    

    Corresponding CMakeLists.txt:

    cmake_minimum_required(VERSION 3.1.0)
    
    # Define project name
    project(hellogl2)
    
    # set desired Qt version
    set(QT_VERSION_REQ "5.12.0")
    
    # Find includes in corresponding build directories
    set(CMAKE_INCLUDE_CURRENT_DIR ON)
    
    # Instruct CMake to run moc automatically when needed
    set(CMAKE_AUTOMOC ON)
    
    # Create code from a list of Qt Designer ui files
    set(CMAKE_AUTOUIC ON)
    
    # Find libraries
    # find_package(Qt5Core ${QT_VERSION_REQ} CONFIG REQUIRED)
    # find_package(Qt5Quick ${QT_VERSION_REQ} CONFIG REQUIRED)
    find_package(Qt5Widgets ${QT_VERSION_REQ} CONFIG REQUIRED)
    # find_package(Qt5Gui ${QT_VERSION_REQ} CONFIG REQUIRED)
    
    set(hellogl2_SRCS
        mainwindow.cpp
        window.cpp
        glwidget.cpp
        logo.cpp
        main.cpp
    )
    
    # Tell CMake to create the executable
    add_executable(${PROJECT_NAME} MACOSX_BUNDLE ${hellogl2_SRCS})
    
    target_link_libraries(${PROJECT_NAME}
        Qt5::Widgets
    )
    

    Kind regards,
    Anthony


Log in to reply