Hi to all,
I'm writing a config dialog that I exec from my main application.
With the dialog the user can choose the colors that will be used to draw an audio waveform.
In the dialog I would show a preview of the waveform so I added a little QFrame named previewFrame and in the paintEvent I would
draw a little sine function over it.

This is part of the code of the paint event.

Qt Code:
  1. void ConfigDlg::paintEvent( QPaintEvent* event )
  2. {
  3. int h = ui.previewFrame->height();
  4. int w = ui.previewFrame->width();
  5.  
  6. QPainter p( ui.previewFrame ); //<--give error!!!!!!!!
  7. p.setRenderHint( QPainter::Antialiasing, true );
  8. p.fillRect( 0, 0, w, h, bgColor );
  9. QPen pen = QPen( Qt::darkRed, 1 );
  10. }
To copy to clipboard, switch view to plain text mode 

The problem is that I get the following error
QPainter::begin: Paint device returned engine == 0, type: 1
QPainter::setRenderHint: Painter must be active to set rendering hints
Where the code is wrong?

Best Regards