I am getting the following errors:
QWidget::repaint: Recursive repaint detected.
QPainter::begin: A paint device can only be painted by one painter at a` time.
QPainter::beginNativePainting: Painter not active.
QPainter::setRenderHint: Painter must be active to set rendering hints.
QPainter::translate: Painter not active.
void Graficador::paintEvent(QPaintEvent *event){
QPainter painter;
painter.begin(this);
painter.beginNativePainting();
painter.setRenderHint(QPainter::Antialiasing);
painter.translate(250, 250);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1.0,1.0,-1.0,1.0,-1.0,1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClearColor(0.2,0.4,0.3,1);
glClear(GL_COLOR_BUFFER_BIT);
std::vector<unsigned short> nodosaux;
glPushMatrix();
for (unsigned i=1;i<=automata->Dimension();i++)
{
nodosaux=(automata->operator [](i))->Nodos();
if((automata->operator [](i))->Estado()==0)
glColor3f(0.3,0.3,0.3);
else if((automata->operator [](i))->Estado()==1.0)
glColor3f(1.0,1.0,1.0);
else if((automata->operator [](i))->Estado()==2.0)
glColor3f(0.7,0.7,0.7);
glBegin(GL_POLYGON);
for(unsigned j=1;j<=nodosaux.size();j++)
{
glVertex2f(automata->Nodo(nodosaux[j-1]).first,
automata->Nodo(nodosaux[j-1]).second);
}
glEnd();
glColor3f(0.0,0.0,0.0);
glBegin(GL_LINE_LOOP);
for(unsigned j=1;j<=nodosaux.size();j++)
{
glVertex2f(automata->Nodo(nodosaux[j-1]).first,
automata->Nodo(nodosaux[j-1]).second);
}
glEnd();
}
glPopMatrix();
glPushMatrix();
glColor3f(1.0f,1.0f,1.0f);
glBegin(GL_LINES);
glVertex2f(-500.0,0.0);
glVertex2f(500.0,0.0);
glVertex2f(0.0,-500.0);
glVertex2f(0.0,500.0);
glEnd();
glPopMatrix();
painter.endNativePainting();
painter.end();
}
(Sorry for the use of operator, I know that its not the proper use but I need to solve this problem first).
This is the paintEvent() of a QGLWidget. I had no problem until I started using a pointer of my class "automata". This class only have some vectors with the coordinates (x,y) of the vertices, so I have no idea why I have this problem.
The complete program has a big class System that has inside: a user interface, an automata and some other classes that are used for other tasks. The user interface has this QGLWidget inside, and the automata that I'm trying to use here is a pointer that points to the automata in the system class.
I'm passing that pointer like this:
void Cargar_automata(Automata_Celular* ac)
{
automata = new Automata_Celular();
automata =ac;
}
I have some other widgets but they are only buttons to manage files and timers.