QGLWidget w = new QGLWidget();
w->makeCurrent();
QString str = w->format(); //error:no suitable conversion from QGLFormat to QString
在上面的代码中:
W->格式(); //返回QGLFormat
答案 0 :(得分:1)
QGLFormat
包含许多属性,因此为了将其转换为QString
,您需要将所需的属性连接成一个字符串。
QGLFormat format = ...
QString str = "Info:\n";
str += "version:" QString::number(format.majorVersion()) + "\n";
str += "red buffer size:" + QString::number(format.redBufferSize()) + "\n";
str += "green buffer size:" + QString::number(format.greenBufferSize()) + "\n";
str += "blue buffer size:" + QString::number(format.blueBufferSize());
// Here you can use 'str' as a QString