Hello everybody,

As it is expressed in the thread title, I would like to know how to optimize the drawing process of a pixmap in the paintEvent function.

Let me give you some more explanations about my application. I have an interface between my application and a radio system so I am able to get the current radio frequency. I want to display the radio frequency in my application and I use ten pixmaps (one for each digits) which have some transparency. When a frequency scan is started, the digits are changed according to the real radio frequency and it flicks and I don't know how to do to eliminate it.

The widget which process the displaying of the digits is constructed with the following style :
Qt Code:
  1. Qt::WStyle_Customize|Qt::WStyle_NoBorder|Qt::WNoAutoErase
To copy to clipboard, switch view to plain text mode 

and here are the two functions I use to display the digit pixmaps :
Qt Code:
  1. void CMyClass::displayImage(const QPixmap& pix)
  2. {
  3. if( transparency )
  4. {
  5. if ( pix.mask() )
  6. this->setMask( *pix.mask() );
  7. }
  8. // We can use the following code if we are sure that the source and destination graphic devices have the same depth
  9. //QRect rect(event->rect());
  10. //bitBlt(this, rect.topLeft(), &pixmap);
  11.  
  12. // We must use the following code if we are sure that the source and destination graphic devices have a different depth
  13. QPainter painter(this);
  14. painter.drawPixmap(0, 0, pix);
  15. }
  16.  
  17. void CMyClass::paintEvent(QPaintEvent* event)
  18. {
  19. if( this->isShown )
  20. {
  21. if( loadingMode == CMyClass::Static )
  22. {
  23. QPixmap pixmap(images[imageCurrentIndex]);
  24.  
  25. displayImage(pixmap);
  26. }
  27. else if( loadingMode == CMyClass::Dynamic )
  28. {
  29. QPixmap pixmap(files[imageCurrentIndex]);
  30.  
  31. displayImage(pixmap);
  32. }
  33. }
  34. }
To copy to clipboard, switch view to plain text mode 

So if someone could tell me how to optimize my diplaying process, it would be great.

Thanks in advance.