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.
{
int h = ui.previewFrame->height();
int w = ui.previewFrame->width();
QPainter p
( ui.
previewFrame );
//<--give error!!!!!!!! p.
setRenderHint( QPainter::Antialiasing,
true );
p.fillRect( 0, 0, w, h, bgColor );
}
void ConfigDlg::paintEvent( QPaintEvent* event )
{
int h = ui.previewFrame->height();
int w = ui.previewFrame->width();
QPainter p( ui.previewFrame ); //<--give error!!!!!!!!
p.setRenderHint( QPainter::Antialiasing, true );
p.fillRect( 0, 0, w, h, bgColor );
QPen pen = QPen( Qt::darkRed, 1 );
}
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
Bookmarks