How to cast QEvent objects?

  • Richard Evans

    Richard Evans - 2003-01-18

    I've installed an eventFilter to capture key presses without problem, but I need to cast the passed event object in my eventFilter() method to the correct type before I can actually do anything useful.

    In C++ its simple (eg):

      QKeyEvent *k = (QKeyEvent *)e;

    How can I do this with PQt?

    As ever, thanks for your help.

    • germain garand

      germain garand - 2003-01-18

      Hi richard,
      since 3.004 you can :

      CAST $e, "Qt::KeyEvent";

      But beware :  it changes directly the $e object and doesn't do any kind of checking...

      • Richard Evans

        Richard Evans - 2003-01-19

        Thanks Germain, works perfectly.

        > and doesn't do any kind of checking...

        Sounds just like my code :)



Log in to post a comment.