Hi to all,
I would put in a separate thread a method of my class that actually blocks the gui.
The method is responsible of drawing an audio waveform into a QWidget in the paint event
So:
{
// Update the ev->rect area with the wave from the rendered QPixmap here
if( m_waveCachePixmap.isNull() )
{
updateWave();// BLOCK MY GUI
}
p.
setRenderHint( QPainter::Antialiasing,
true );
// wave
p.drawPixmap( 0, 0, m_waveCachePixmap );
}
void WaveDisplay::paintEvent( QPaintEvent* pe )
{
// Update the ev->rect area with the wave from the rendered QPixmap here
if( m_waveCachePixmap.isNull() )
{
updateWave();// BLOCK MY GUI
}
QPainter p( this );
p.setRenderHint( QPainter::Antialiasing, true );
QPen pen = QPen( Qt::darkRed, 1 );
// wave
p.drawPixmap( 0, 0, m_waveCachePixmap );
QWidget::paintEvent(pe);
}
To copy to clipboard, switch view to plain text mode
AND
// THIS ROUTINE BLOCK MY GUI
void WaveDisplay::updateWave()
{
int h = this->height();
int w = this->width();
// I want another width and height here.
// Also, you might to clear the cache at resize events
//p.setRenderHint( QPainter::Antialiasing, true );
p.fillRect( temp.rect(), bgColor );
...more code to draw the wave...
}
// THIS ROUTINE BLOCK MY GUI
void WaveDisplay::updateWave()
{
int h = this->height();
int w = this->width();
// I want another width and height here.
// Also, you might to clear the cache at resize events
QPixmap temp = QPixmap( w, h );
QPainter p( &temp );
//p.setRenderHint( QPainter::Antialiasing, true );
p.fillRect( temp.rect(), bgColor );
...more code to draw the wave...
}
To copy to clipboard, switch view to plain text mode
I read about threads and QtConcurrent but I don't know how to adapt my code even because I have to pass the painter
and paint on a specific widget.
I hope to get help.
Regards
Bookmarks