QPainter error saving an image from a QGraphicsScene
Hi to all,
I'm now compiling, without errors, a project using the latest Qt release (4.6) and created with the previous Qt 4.5.4 release (Windows).
I'm coding my function using the example reported in "The Graphics View Framework" included in the Qt Help but now it isn't working. The message :
Code:
QPainter::begin: Paint device returned engine
== 0, type
: 2
is appearing in my "Application Out"!!!
Here is the code:
Code:
void frmStats::creaFileHtml()
{
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN "
"http://www.w3.org/TR/html4/strict.dtd\">\n"
"<html>\n"
"<head>\n"
"<meta content=\"text/html;"
"charset=UTF-8\" http-equiv=\"content-type\">\n"
"<title></title>\n"
"</head>\n"
"<body>\n";
"</body>\n"
"</html>\n";
html.clear();
html += intestazioneFile;
painter.
setRenderHint(QPainter::Antialiasing);
scene->render(&painter); // scene = new QGraphicsScene(QRect(0, 0, endX, endY), this);
painter.end();
pixmap.
save(QDir::currentPath() + "/statistiche.png");
html
+= "<img src=\"" + QDir::currentPath() + "/statistiche.png\" ALIGN=\"center\">\n<br>\n";
html += chiusuraFile;
// qDebug() << "HTML: " << html;
}
What happens?
Thanks!
Re: QPainter error saving an image from a QGraphicsScene
Sorry guys, it has been a my error!
Solved.
Re: QPainter error saving an image from a QGraphicsScene
Could you explain how you solved your problem?
Re: QPainter error saving an image from a QGraphicsScene
Ok, but I'm warning you, it's quite strange. So I've commented the problem core lines:
Code:
// painter.setRenderHint(QPainter::Antialiasing);
// scene->render(&painter);
// painter.end();
// pixmap.save(QDir::currentPath() + "/statistiche.png");
leaving only the QPainter declaration. That to find which instruction was the problem. And Taaa Daaa line by line I arrived at the end without having the error anymore!!!
I don't know if it depends by the compiler (just a flicker) or my PC but now is working, that's my honest work, believe or not.