Hi to all,
I attached a QWidget to a scrollarea. The widget is scrolled automatically and I draw a text on the position 20, 20.
The problem is that when the widget is scrolled the text disappear. I draw the text in the paint event so:

Qt Code:
  1. void WaveDisplay::paintEvent( QPaintEvent* pe )
  2. {
  3. if( m_waveCachePixmap.isNull() )
  4. {
  5. updateWave();
  6. }
  7.  
  8. QPainter p( this );
  9. p.setRenderHint( QPainter::Antialiasing, true );
  10. QPen pen = QPen( Qt::darkRed, 1 );
  11.  
  12. // wave
  13. p.drawPixmap( 0, 0, m_waveCachePixmap );
  14.  
  15. // timeline
  16. pen.setColor(Qt::darkRed);
  17. pen.setStyle(Qt::SolidLine);
  18. p.setPen( pen );
  19. p.drawLine( m_CurrentTimePosition, 0, m_CurrentTimePosition, height() );
  20.  
  21. // elapsed time
  22. QWidget* widget = area->viewport(); //HOW CAN I USE THE VIEW PORT
  23. setElapsedTime( m_CurrentSoundPosition );
  24. QFont font = p.font();
  25. font.setPointSize( 24 );
  26. p.setFont( font );
  27. p.drawText( QPoint(20, 20), m_elapsedTimeString ); //THE TEXT DISAPPEAR
  28.  
  29. QWidget::paintEvent(pe);
  30. }
To copy to clipboard, switch view to plain text mode 

I read about the viewport but I don't know how use it for my purpose.
I would always draw at a position of the viewport of my scrollarea.

regards