QT & OpenGl moving screen : im using qWidget which inhertis QGLWidget and below the widget i have 2 buttons.
button1: +
button2: -

this is my code:

    void GLWidget::paintGL() {
    
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho(0,_w,0,_h,-1,1);
        glViewport(_camera_pos_x,0,_w,_h);
    
        glBegin(GL_LINES);
            glVertex2i(50,50);
            glVertex2i(200,200);
        glEnd();
    
       update();
    }

i want each time im pressing the + the screen will move 10 pixels to the right which means the line shuld move to the left by 10 pixels.

this is the code when im pressing the button:

    void right() {_camera_pos_x += 10;}

_camera_pos_X is just a member int which is intialized to 0.

when im pressing the button another line is rendered 10 pixels to the right and i see 2 lines

what's wrong with my code?

by the way, I think im using old code of OpenGl, is there a better way to render a line?