本页内容

QOpenGLVersionProfile Class

QOpenGLVersionProfile 类表示 OpenGL 上下文的版本,以及(如适用)其配置文件。更多内容...

头文件: #include <QOpenGLVersionProfile>
CMake: find_package(Qt6 REQUIRED COMPONENTS OpenGL)
target_link_libraries(mytarget PRIVATE Qt6::OpenGL)
qmake: QT += opengl

公共函数

QOpenGLVersionProfile()
QOpenGLVersionProfile(const QSurfaceFormat &format)
QOpenGLVersionProfile(const QOpenGLVersionProfile &other)
~QOpenGLVersionProfile()
bool hasProfiles() const
bool isLegacyVersion() const
bool isValid() const
QSurfaceFormat::OpenGLContextProfile profile() const
void setProfile(QSurfaceFormat::OpenGLContextProfile profile)
void setVersion(int majorVersion, int minorVersion)
std::pair<int, int> version() const
QOpenGLVersionProfile &operator=(const QOpenGLVersionProfile &rhs)

详细说明

该类的对象可传递给 QOpenGLContext::versionFunctions(),以请求特定版本和配置文件的 OpenGL 函数对象。

它还包含一些辅助函数,用于检查某个版本是否支持配置文件,或者是否为旧版。

成员函数文档

QOpenGLVersionProfile::QOpenGLVersionProfile()

创建一个默认的无效 QOpenGLVersionProfile 对象。

[explicit] QOpenGLVersionProfile::QOpenGLVersionProfile(const QSurfaceFormat &format)

创建一个 QOpenGLVersionProfile 对象,该对象使用format 中的版本和配置文件进行初始化。

QOpenGLVersionProfile::QOpenGLVersionProfile(const QOpenGLVersionProfile &other)

创建other 的副本。

[noexcept] QOpenGLVersionProfile::~QOpenGLVersionProfile()

销毁QOpenGLVersionProfile 对象。

bool QOpenGLVersionProfile::hasProfiles() const

如果由version() 返回的 OpenGL 版本支持配置文件,则返回true 。只有 OpenGL 3.2 及以上版本支持配置文件。

另请参阅 profile() 和version()。

bool QOpenGLVersionProfile::isLegacyVersion() const

返回true ,即version() 返回的 OpenGL 版本。该函数包含已弃用的函数,且不支持配置文件,即当 OpenGL 版本 <= 3.1 时。

bool QOpenGLVersionProfile::isValid() const

如果版本号有效,则返回true 。请注意,对于通过默认构造创建的QOpenGLVersionProfile 对象,该函数将返回false 。

另请参见 setVersion() 和version()。

QSurfaceFormat::OpenGLContextProfile QOpenGLVersionProfile::profile() const

返回 OpenGL 配置文件。仅当该版本支持配置文件时,此操作才有意义。

另请参阅 setProfile()。

void QOpenGLVersionProfile::setProfile(QSurfaceFormat::OpenGLContextProfile profile)

设置 OpenGL 配置文件profile 。仅当该版本支持配置文件时,此设置才有意义。

另请参阅 profile()。

void QOpenGLVersionProfile::setVersion(int majorVersion, int minorVersion)

将主版本号和次版本号分别设置为majorVersion 和minorVersion 。

另请参阅 version()。

std::pair<int, int> QOpenGLVersionProfile::version() const

返回一个 std::pair<int,int>,其中两个元素分别表示 OpenGL 的主版本号和次版本号。

另请参阅 setVersion()。

QOpenGLVersionProfile &QOpenGLVersionProfile::operator=(const QOpenGLVersionProfile &rhs)

将rhs 的版本和配置文件分配给此QOpenGLVersionProfile 对象。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.