I am currently porting an open source solution (ATM Albatross solution http://www.albatross.aero/ ) from Qt3 to Qt5. Albatross is an air traffic observer that requires very good results. There are various problems that I managed to manage, but not part of the display.
The display architecture is based on the bitblt command, which first copies one pixmap to another and finally copies pixmap to the screen.
Here is the Qt3 mapping code (working and executive) :
void CAsdView::paintEvent ( QPaintEvent * Event) { QRect rcBounds=Event->rect(); QPainter tmp; for (int lay=0;lay<(int)m_RectTable.size();lay++)
I tried replacing bitblt with drawPixmap , but the performance is very poor since I have to display the screen often.
Here is the new Qt5 code:
void CAsdView::paintEvent ( QPaintEvent * Event) { QRect rcBounds=Event->rect(); QPainter tmp; for (int lay=0;lay<(int)m_RectTable.size();lay++) { if (!m_RectTable.at(lay).isEmpty()) { tmp2.begin(m_BitmapTable[lay]); if (lay != 0) { tmp.drawPixmap(m_RectTable[lay].left(), m_RectTable[lay].top(), *m_BitmapTable.at(lay - 1), m_RectTable[lay].left(), m_RectTable[lay].top(), m_RectTable[lay].width(), m_RectTable[lay].height());//TOCHECK m_BitmapTable[lay] = m_BitmapTable[lay - 1].copy(m_RectTable[lay]); } if (lay==0) tmp.fillRect(m_RectTable.at(lay), *m_pBrush); OnDraw(&tmp, lay); tmp.end(); m_RectTable[lay].setRect(0, 0, -1, -1); } } tmp.begin(this); tmp.drawPixmap(rcBounds.left(), rcBounds.top(), m_BitmapTable.at(m_LayerNb - 1), rcBounds.left(), rcBounds.top(), rcBounds.width(), rcBounds.height()); tmp.end(); }
There are 3 layers for layers. Layer 0 is the deepest (background), layer 2 is the highest. This configuration is used to ensure that air traffic is always displayed at the top of the screen.
The OnDraw method draws elements that have changed since the last paintEvent, depending on the layer
Q: Do you have any ideas on how I could improve this paintEvent method to return to good behavior and again have good results with Qt5?