QT5 LinuxFB rotation for LCDs patch

I wrote up this patch as I needed to get a landscape display on a LCD which was actually intended for portrait (and so its resolution and framebuffer had to be setup for portrait, it was just physically oriented as landscape). This is a common problem for people using ILI9341/ILI9340 controllers found on cheapo TFT LCDs. These LCDs come setup for a portrait mode on the RGB interface with no option to change it, they do have an SPI interface where you can alter the settings but the display data must always be sent over SPI.

This other problem is going from QT4 to QT5, the transformation options previously available were removed with the old QWS system and now QT5 doesn’t have any way to rotate the image going to the framebuffer.

This patch improves the LinuxFB platform plugin to create an rotation option which can rotate the display by 90,180 and 270 degrees.

Usage is simple, simply append the rotation= parameter with a value of 0,90,180, or 270:

export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb0:rotation=90

Or use it in the program launch args

-platform linuxfb:fb=/dev/fb0:rotation=90

You need to recompile qtbase to apply this. This was done against QT5.4 but I doubt the files being modified have changed since QT5 was released.

Download here: qt5.4_linuxfb_rotation.patch

  • Azaddou

    hello, could you please show me how to apply the patch and recompile qtbase

  • Ilia

    Thank you so much! You saved a couple of my days.
    Works perfectly on Qt 5.3.2.

    • herego

      Hello,I patch on Qt 5.3.2,but I lose my mouse and it’s not working right.Please can you tell me how to do?

      • Ilia

        Oh, we don’t have mouse cursor in our application at all (medical device with specific keyboard), so I can’t say anything about mouse correctness, sorry.

        • herego

          I see! Thank you very much!

  • Bibindoum

    Hi, I’m working with Qt5.5, and I had the same problem as you. Thus, i applied your patch in order to correct it.
    However, even though my app is displayed in portrait mode, the touchscreen does still react as if it was in landscape mode (i.e. buttons are only triggered if we touch on their previous place)
    I tried to set the suitable environment variable QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS with rotate, but it does not change.
    I’m wondering of modifying your patch to enable this rotation.
    Do you any insight to give on this ?

  • Yoav

    Hi Bibindoum, was this fixed for you?