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::WStyle_Customize|Qt::WStyle_NoBorder|Qt::WNoAutoErase
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 :
void CMyClass::displayImage(const QPixmap& pix)
{
if( transparency )
{
if ( pix.mask() )
this->setMask( *pix.mask() );
}
// We can use the following code if we are sure that the source and destination graphic devices have the same depth
//QRect rect(event->rect());
//bitBlt(this, rect.topLeft(), &pixmap);
// We must use the following code if we are sure that the source and destination graphic devices have a different depth
painter.drawPixmap(0, 0, pix);
}
{
if( this->isShown )
{
if( loadingMode == CMyClass::Static )
{
QPixmap pixmap
(images
[imageCurrentIndex
]);
displayImage(pixmap);
}
else if( loadingMode == CMyClass::Dynamic )
{
QPixmap pixmap
(files
[imageCurrentIndex
]);
displayImage(pixmap);
}
}
}
void CMyClass::displayImage(const QPixmap& pix)
{
if( transparency )
{
if ( pix.mask() )
this->setMask( *pix.mask() );
}
// We can use the following code if we are sure that the source and destination graphic devices have the same depth
//QRect rect(event->rect());
//bitBlt(this, rect.topLeft(), &pixmap);
// We must use the following code if we are sure that the source and destination graphic devices have a different depth
QPainter painter(this);
painter.drawPixmap(0, 0, pix);
}
void CMyClass::paintEvent(QPaintEvent* event)
{
if( this->isShown )
{
if( loadingMode == CMyClass::Static )
{
QPixmap pixmap(images[imageCurrentIndex]);
displayImage(pixmap);
}
else if( loadingMode == CMyClass::Dynamic )
{
QPixmap pixmap(files[imageCurrentIndex]);
displayImage(pixmap);
}
}
}
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.
Bookmarks