OpenGL and Qt-Creator

This post is a simple example of an OpenGL widget display in a Qt window. This example has been programmed with the following software versions:

  • Xubuntu 14.04 LTS
  • Qt Creator 3.0.1
  • Qt 5.2.1 (GCC 4.8.2, 64 bit)


This application display a 3-axis frame and a cube made of points:

Software installation

You may need to install the OpenGL Utility Toolkit (GLUT):

sudo apt-get install freeglut3 freeglut3-dev


3 thoughts on “OpenGL and Qt-Creator

  1. Hello,

    I would like to repeat the project as it shows in the Video above but I have slight problem with the movement of the 3D rectangle.

    I have an Arduino Leonardo and an MPU9250 Sensor. When I make the connections and compile and run the GUI, the Program will detect the movement of the sensor fairly well but there is one issue. When I don’t move the sensor at all the GUI 3D rectangle still keeps slowly changing its position mainly in one direction.

    Is there a section in the algorithm that would allow me to calibrate the output on the GUI screen, since the raw x y z data is constant when the sensor module is not moved.

    Any help would really be appreciated.


    1. The magnetometer is influenced by close environment (PCB, magnets, metal, hard drives …). The value returned also depends on your latitude, because the magnetic field is not constant on earth. So the magnetometer must be calibrated. It’s too long to explain in this post, but if you Google magnetomer + calibration, you’ll find a lot of useful information. This is probably the origin of your problem.

  2. Supporting P.L.: this is an analog device of major complexity. One of the most difficult problems with devices like this is getting zero output with nothing happening. Set the device down and monitor it for a while. Capture the outputs and put the data in something like Excel to chart and understand. Then you can calibrate out most of the drift. EXPECT to have some residual drift that you just cannot totally eliminate. Try to avoid use of absolute values and go mostly for deltas (what has changed lately).

Leave a Reply

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