0

调用 QGLShaderProgram::link() 时有没有办法关闭日志消息? http://qt-project.org/doc/qt-4.8/qglshaderprogram.html#link

消息如下所示:

QGLShader::link: "Vertex shader(s) linked, fragment shader(s) linked.
"

Qt 代码如下所示:src/opengl/qglshaderprogram.cpp:893

    glLinkProgram(program);
    value = 0;
    glGetProgramiv(program, GL_LINK_STATUS, &value);
    d->linked = (value != 0);
    value = 0;
    glGetProgramiv(program, GL_INFO_LOG_LENGTH, &value);
    d->log = QString();
    if (value > 1) {
        char *logbuf = new char [value];
        GLint len;
        glGetProgramInfoLog(program, value, &len, logbuf);
        d->log = QString::fromLatin1(logbuf);
        QString name = objectName();
        if (name.isEmpty())
            qWarning() << "QGLShader::link:" << d->log;
        else
            qWarning() << "QGLShader::link[" << name << "]:" << d->log;
        delete [] logbuf;
    }
    return d->linked;
}
4

1 回答 1

1

因此,似乎唯一可能的解决方案是重定向 qWarning(),如:如何重定向 qDebug、qWarning、qCritical 等输出?

 qInstallMsgHandler([](QtMsgType , const char* ) { });  // empty message handler
 bool result = program.link();
 qInstallMsgHandler(0);  // restore default message handling
于 2012-06-12T14:46:59.443 回答