For mouse events, there are three functions you can override: mousePressEvent(), mouseMoveEvent(), and mouseReleaseEvent()void GLWidget::initializeGL() { glClearColor(0.5, 0.5, 0.5, 1.0);}void GLWidget::resizeGL(int width, int height) { glViewport(0, 0, width(), height()); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0, width(), 0, height()); glMatrixMode(GL_MODELVIEW); glLoadIdentity();}void GLWidget::paintGL() { glClear(GL_COLOR_BUFFER_BIT); // draw a red triangle glColor3f(1,0,0); glBegin(GL_POLYGON); glVertex2f(10,10); glVertex2f(10,600); glVertex2f(300,10); glEnd();} 这篇关于如何在QGLWidget中寻找OpenGL的等效功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-21 07:04