Okay so I tried doing as you said but two things happened:
the z axis isn't visible and the coordinate system doesn't seem to be attached to the object however I drew it right after drawing the object.
In the previous code where the coordinate system's axes have the same texture as the object, the axes were attached to the object.
When the object rotates, the axes rotate too but now they seem to be detached from the object.
Also here is the new code:
void MainWidget::paintGL()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//! [6]
// Calculate model view transformation
QMatrix4x4 matrix;
matrix.lookAt(QVector3D(1.0, 2.0, 0.0), QVector3D(0.0,0.0,-5.0),QVector3D(0.0,1.0,0.0));
matrix.translate(0.0, 0.0, -5.0);
matrix.scale(0.5,0.5,0.5)
program.setUniformValue("mvp_matrix", projection * matrix);
draw_object();
draw_frame();
}
void MainWidget::draw_object()
{
program.bind();
texture->bind();
program.setUniformValue("texture", 0);
geometries->drawCubeGeometry(&program);
texture->release();
program.release();
}
Draw_Frame()
{
glLineWidth(8.0f);
glBegin(GL_LINES);
//X_axis
glColor3f(1.0, 0.0, 0.0);
glVertex3f(0.0, 0.0, 0.0);
glVertex3f(4.0, 0.0, 0.0);
//Y_axis
glColor3f (0.0, 1.0, 0.0);
glVertex3f(0.0, 0.0, 0.0);
glVertex3f(0.0, 4.0, 0.0);
//Z_axis
glColor3f (0.0, 0.0, 1.0);
glVertex3f(0.0, 0.0, 0.0);
glVertex3f(0.0, 0.0, 4.0);
glEnd();
}