Home » Code » Qt Patches: QGraphicsView & QImageWriter

Qt Patches: QGraphicsView & QImageWriter

posted by Andy Maloney


Two and a half years ago I wrote about a UX bug with QGraphicsView where it would reset the selection in the view if you tried to extend it with a rubberband selection. I have been using those changes in the version of Qt I maintain for my software.

I finally took the time to figure out how to use the gerrit code review system for submitting patches to the Qt project, and worked with several other developers to get it in shape for merging into the codebase for Qt 5.5.

Qt Library

Qt Library

The way I implemented the changes in my old post was inelegant but functional, so I cleaned it up for submission. Then, based on suggestions from Andreas Hanssen, Dominik Haumann, and Thorbjørn Martsum, took it to the next level to make it elegant. I was even forced to add tests before it would be accepted! <gasp> (Thanks again guys!)

The changes will appear in Qt 5.5, but they will not be backported to Qt4. I have, however, created patches for both if you need to use them:

Qt4 Patch: QGraphicsView_Rubberband_Select_Qt4_patch.diff

Qt5 Patch: QGraphicsView_Rubberband_Select_Qt5_patch.diff


I also revisited my patch from three years ago for QImageWriter which added the ability to turn on the optimize and progressive scan switches for writing JPEGs, which I also was maintaining in my own version of Qt.

This work had input from another developer, Gunnar Sletta, and became a better commit because of it (thanks Gunnar!).

These changes will also be part of Qt 5.5 and won’t be backported to Qt4. I have created patches for both Qt4 and Qt5 if you need them:

Qt4 Patch: QImageWriter_Qt4_patch.diff

Qt5 Patch: QImageWriter_Qt5_patch.diff

I hope these changes and patches are useful to someone out there. Based on this positive experience I hope to contribute more small changes I have lying around somewhere…


  1. Comment by dhaumann:

    Thanks again for taking the time to get this patch in, very much appreciated!

    • Comment by Andy Maloney:

      Thanks Dominik. I appreciated all the input and guidance!

      I’m happy to hear that others find it useful. The QGraphicsView one felt like such a glaring oversight in the UX that I couldn’t ship my software without it working properly.

      With these changes in Qt 5.5 I’m hoping I don’t have to maintain my own version of Qt now 🙂

  2. Comment by Adrien Tétar:

    Hi, just wanted to say thanks for upstreaming these patches! Now I just need to wait for the new PyQt to come out.

Leave a Reply

Your email address will not be published. Required fields are marked *