【发布时间】:2012-02-24 22:14:33
【问题描述】:
我正在尝试将 QWebElement 渲染为 QWidget,但我的应用程序崩溃了,但是如果我将其渲染为 QImage,一切正常。
这是我的代码:
// using this code my application is crashing
void ImageWidget::paintEvent(QPaintEvent *)
{
if (this->imgElement != NULL)
{
QPainter p(this);
this->imgElement->render(&p);
p.end();
}
}
// using this one everything works OK
void ImageWidget::saveImage(QWebElement *el)
{
this->imgElement = el;
QImage m_image = QImage(290, 80, QImage::Format_ARGB32_Premultiplied);
m_image.fill(Qt::transparent);
QPainter p(&m_image);
el->render(&p);
p.end();
m_image.save("some_file.png", "png");
this->update();
}
我在 Win 7 (x64) 上使用 Qt 4.7.3。让我知道如何解决这个问题。
【问题讨论】:
-
在
QImage示例中,m_image是ImageWidget的成员?