Originally Posted by
wysota
You mean now or when? Because none of the code you pasted does what I said.
Here my last code:
{
if( m_waveCachePixmap.isNull() )
{
updateWave();
}
p.
setRenderHint( QPainter::Antialiasing,
true );
//wave
p.drawPixmap( 0, 0, m_waveCachePixmap );
//timeline
p.setPen(pen);
p.drawLine( m_CurrentTimePosition, 0, m_CurrentTimePosition, height() );
}
void WaveWidget::paintEvent( QPaintEvent* pe )
{
if( m_waveCachePixmap.isNull() )
{
updateWave();
}
QPainter p( this );
QPen pen = QPen(Qt::blue, 1);
p.setRenderHint( QPainter::Antialiasing, true );
//wave
p.drawPixmap( 0, 0, m_waveCachePixmap );
//timeline
p.setPen(pen);
p.drawLine( m_CurrentTimePosition, 0, m_CurrentTimePosition, height() );
}
To copy to clipboard, switch view to plain text mode
and the setCurrentTimePosition (as in my last post):
void WaveWidget::setCurrentTimePosition()
{
uint newTimeValue = getCurrentPos();
/* trasform time coord in widget coord */
qreal samplesPerPixel = m_wave->getSamples() / width();
qreal x_pos = newTimeValue / samplesPerPixel;
if( x_pos == m_CurrentTimePosition )
return; //no change
QRect r
= QRect( m_CurrentTimePosition
- 1,
0, x_pos, height
() );
update( r );
/* update current pos */
m_CurrentTimePosition = x_pos;
}
void WaveWidget::setCurrentTimePosition()
{
uint newTimeValue = getCurrentPos();
/* trasform time coord in widget coord */
qreal samplesPerPixel = m_wave->getSamples() / width();
qreal x_pos = newTimeValue / samplesPerPixel;
if( x_pos == m_CurrentTimePosition )
return; //no change
QRect r = QRect( m_CurrentTimePosition - 1, 0, x_pos, height() );
update( r );
/* update current pos */
m_CurrentTimePosition = x_pos;
}
To copy to clipboard, switch view to plain text mode
Is what did you suggested to me?
Bookmarks