Qt World Summit: Submit your Presentation

Display a colormap in polar coordinates in a Qt Widget

  • Hello everyone
    I'm writing to ask for help to solve this problem that is bothering me for few weeks.
    I have three vectors of real numbers: one with radius coordinates (M elements), one with angle coordinates (N elements) and one with a colormap with one element for each radius/angle coordinate (MxN elements).
    Then I have a Qt program made with QtCreator and I need to display such colormap in a widget.

    • I tried QCustomplot, but it does not manage radius/angle coordinates. I need to create a rectangular grid and interpolate my colormap matrix, which is very slow and depends on how I create such grid.

    • Then I tried Qwt, but the documentation I found was quite poor and I wasn't even able to install it >.<

    • Then I tried with QML. I managed to achieve something, but it is still too slow (my application needs to be quasi real-time and to display a matrix of more than 10,000 elements in less than half of a second, preferably avoiding for loops). Moreover it also gives me "segmentation fault" issues too. Moreover, its appearance does not quite satisfy me. I used the spectrogram example and the qml Surface object.

    • Then I thought about the python library matplotlib. As the pcolor function appears does satisfy me and it should not be too slow to display (I'm quite a noob with Qt, but familiar with MatLab). However, I'm having some of a hard time just to do the following:

      1. Take the python code that displays my radius/angle colormap with the matplotlib library (I already have it);
      2. Embed this code in my qt c++ application;
      3. Put the pcolor result in a qt widget instead of an external figure.

    I won't use PyQt because that would mean to take just my ui file and re-write my whole code in Python (which I am not familiar at all). The application I wrote in c++ is quite "big" and it manages TCP connections and sockets too, so it would be very very difficult for me to re-write it in python in short time.

    I tryed to also study these
    but it seems I would need quite some time to study the whole thing and I don't even know if the python way would be the best choice.

    Can someone help me with my problem?
    Thank you in advance and best regards :-)

  • Is there anybody?

  • Moderators

    I can't really comment on the coordinate transformations, but about the preferred render stacks.

    In general, using QML is probably the most future-proof technology, so I'd recommend exploring that further. Maybe your issues with it can be solved? This also opens up the possibility to use the GPU directly, which might come handy for calculations that can be parallelized.

    A decent alternative for drawing things is still GraphicsView : https://doc.qt.io/qt-5/qgraphicsview.html. It was designed specifically to render a scene with lots of items on the CPU.

  • @kkoehne
    If you want it to be fast with that many items changing all the time using a QGraphicsView with a QGraphicsScene might be a tad slow. Unless you are very clever about how you draw the items and set their colours. It is always faster to modify existing items rather than delete and create new ones all the time.
    You might also consider using a QOpenGLWidget in the QGraphicsView. Then you might attain good frame rates for large amounts of data which changes dynamically by using OpenGL functions directly.

Log in to reply