【发布时间】:2014-07-01 04:48:52
【问题描述】:
我在为 GUI 推广我的 QGLWidget 时遇到了 Qt 的问题。 由于我的 QGLWidget 的构造函数是
GLWidget::GLWidget( const QGLFormat& format, QWidget* parent )
: QGLWidget( format, parent ),
m_vertexBuffer( QGLBuffer::VertexBuffer ) {}
所以对象应该像这样被实例化
QGLFormat glFormat;
glFormat.setVersion( 3, 3 );
glFormat.setProfile( QGLFormat::CoreProfile );
glFormat.setSampleBuffers( true );
GLWidget w( glFormat, parent );
但是 ui_mainwindow.h 会自动使用
widget = new GLWidget(centralWidget);
由于每次重新编译 UI 时都会创建新的 ui_mainwindow.h,因此无法对其进行修改。所以我可能不得不在我的 maindwindow.cpp 中说明 GLWidget 的实例化与标准构造函数不同,但使用 QFormat。知道这是怎么做到的吗?
【问题讨论】:
-
事后不能直接打
widget->setFormat(format)吗? -
void setFormat(const QGLFormat & format) 已过时,不应再使用。
标签: qt user-interface widget