Using a custom QGraphicsEffect



  • I think I am misunderstanding something fundamental about QGraphicsEffect. Right now I'm actually trying to create an effect that does nothing: that literally just takes its input pixmap and draws it, unchanged. Based on my reading of the example code and the documentation, the simplest conceivable implementation of the draw() function is:

    void PreviousFrameOverlayEffect::draw(QPainter *painter)
    {
        const QPixmap pixmap = sourcePixmap();
        painter->drawPixmap(pixmap.rect(), pixmap);
    }
    

    I've got my code rigged up so that this effect is only applied while I'm holding down a key on the keyboard. It's being applied to a QCameraViewfinder. The viewfinder shows the correct camera view when the key is not pressed, but when it is pressed, the screen basically goes blank, with just some tiny triangles showing at the left and right edges of the drawing region. Releasing the key to disable the effect drops me back into normal output from the viewfinder. What is wrong with that code? How do I just regurgitate the input pixmap? Obviously that's only the first step in my code, but until I can get that working there's no point in writing the real effect!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.