I have been testing QLogo on the Raspberry Pi, and the performance has been unacceptable. While sitting there doing nothing QLogo uses about 140% of the CPU. My first thought was that maybe I was doing something wrong; this is my fault. After some experimenting, I narrowed the problem down to something between Qt and the OpenGL driver.

Development of Qt and OpenGL is ongoing. For stability I am using the Qt development packages that are available with Raspbian.

Here’s a simple way to see the problem (no need to write code):

  1. Create a new Qt Widgets Application on the Raspberry Pi.
  2. Open up mainwindow.ui.
  3. Add to the MainWindow (you may want to enlarge the window to fit both of these):
    • OpenGL widget, and
    • Text Editor widget
  4. Save and run your application.
  5. Use your favorite CPU monitor to notice that your application is using a lot of CPU when it’s MainWindow has focus.
  6. Type a bunch of lines into the text widget, a few more than the widget can hold.
  7. Now scroll the text in the widget so that the cursor disppears from view. The CPU usage will return to normal.

It seem that the problem occurs when a cursor and an OpenGL widget are present on the same window.

  • If the window loses focus, the cursor disappears and CPU usage is normal.
  • if the cursor is moved outside of the text widget, it disappears and CPU usage is normal.

In another experiment I created two separate windows: one with an OpenGL widget, the other with a Text Edit widget. The CPU usage there was normal. So the problem occurs when there is an editor and an OpenGL widget in the same window. This might be my solution. It means two windows for the user. It complicates the user interface a little, but it adds a bit of flexibility, too.