Hi to all, I'm developing an audio editor that at the moment has basic functionalities as draw the sound waveform, play the sound.
I would implement a time line ( a moving vertical line ) that give to the user an idea of which part of the sound is playing.
In the paintEvent I have to draw the waveform ( cached in a QImage ) and the time line.
This is my paintEvent
{
// Update the ev->rect area with the wave from the rendered QPixmap here
if( m_waveCachePixmap.isNull() )
{
updateWave();
}
p.
setRenderHint( QPainter::Antialiasing,
true );
p.drawImage( 0, 0, m_waveCachePixmap );
QRect
& rect
= QRect(pe
->rect
());
p.setPen(pen);
p.drawLine( rect.x(), 0, rect.x(), height() );
}
void WaveWidget::paintEvent( QPaintEvent* pe )
{
// Update the ev->rect area with the wave from the rendered QPixmap here
if( m_waveCachePixmap.isNull() )
{
updateWave();
}
QPainter p( this );
QPen pen = QPen(Qt::blue, 1);
p.setRenderHint( QPainter::Antialiasing, true );
p.drawImage( 0, 0, m_waveCachePixmap );
QRect& rect = QRect(pe->rect());
p.setPen(pen);
p.drawLine( rect.x(), 0, rect.x(), height() );
}
To copy to clipboard, switch view to plain text mode
I also have to delete the previous line before to draw the new? Or the final result is a growing rectangle. How can I do?
Best,
Franco
Bookmarks