Important: Please read the Qt Code of Conduct -

Using Mouseevent together with Keypressedevents with OPENGL&QT

  • Hello,

    has anybody an idea how can use the "Mousemove event" together with an "Keypress event" for example "Z"-key to change the viewport settings.

    I am using the following example (glwidget.cpp Example File):
    void GLWidget::resizeGL(int width, int height) {
    int side = qMin(width, height);
    glViewport((width - side) / 2, (height - side) / 2, side, side);

     glFrustum(-1.0, +1.0, -1.0, 1.0, near, far);
     glTranslated(0.0, 0.0, -40.0);


    The aim of this (for me frustating) game is to change the to variable "far" and or "near" in an similar mode like in CAD-Systems. a mouse move together with a pressed key.

    Thank you for your help

  • welcome to devnet

    Please use "code wrapping": for your code sections nect time. I have introduced them for you.

Log in to reply