Hi all,
Here, I joined a QGLWidget class QGLWidget in a main window. The glwidget displays well what is contained in the method paintGL ().
But I want to ensure that these methods, those contained in paintGL, are called from the mainwindows by the user according to his need to display.
Here are bits of code most relevant to get an idea of the situation:
mainwindow.cpp:
mainwindow::mainwindow()
{
m_Central->setLayout(m_layout);
m_carto = new GLWidget
m_carto->displayRedTriangle();
m_layout->addwidget(carto);
setCentralWidget(m_Central);
}
mainwindow::mainwindow()
{
m_Central= new QWidget;
m_layout = new QGridLayout;
m_Central->setLayout(m_layout);
m_carto = new GLWidget
m_carto->displayRedTriangle();
m_layout->addwidget(carto);
setCentralWidget(m_Central);
}
To copy to clipboard, switch view to plain text mode
glwidget.cpp:
void GLWidget::paintGL()
{
// some initializing boring parameters
// Setting displayRedTriangle() here will show the red triangle in the user interface.
}
void GLWidget::displayRedTriangle()
{
glBegin(GL_TRIANGLES)
glColor3f(1.0f,0.0f,0.0f)
glVertex3i(-1,0,2);
glVertex3i(1,0,2);
glVertex3i(0,0,0);
glEnd();
}
void GLWidget::paintGL()
{
// some initializing boring parameters
// Setting displayRedTriangle() here will show the red triangle in the user interface.
}
void GLWidget::displayRedTriangle()
{
glBegin(GL_TRIANGLES)
glColor3f(1.0f,0.0f,0.0f)
glVertex3i(-1,0,2);
glVertex3i(1,0,2);
glVertex3i(0,0,0);
glEnd();
}
To copy to clipboard, switch view to plain text mode
So the question is, how to use and make work the displayRedTriangle() from any place that is not directly paintGL?
Thanks for your help,
Best regards.
Cyril
Bookmarks