This is really useful -- many thanks indeed. I'm not bothered about getting in the Mac App Store. Seems like a lot of difficult hoop-jumping just to give Apple a huge percentage of your income, with the added risk of being booted out unexpectedly for no good reason. :-)
Cheers, Martin On 12-01-10 09:42 AM, Chris Meyer wrote: > On Tue, Jan 10, 2012 at 5:13 AM, Martin Holmes<mhol...@uvic.ca> wrote: >> This all seems very disappointing to me. How would you actually use >> webkit to provide SVG support to QImage? > > I extracted this code from my source to convert SVG to QImage using > QtWebKit. It's untested in this specific form, but should give you the > idea. > > And, again, if you want any chance of being accepted on the Mac App > Store, you can't include QtWebKit (at least in its current form, which > uses a library that Apple provides that uses private API calls). > > #include<QGraphicsWebView> > > QImage makeSvgImage(const QSize&svg_size, > const QByteArray&svg_byte_array, > const QString&svg_mime_type) > { > QImage image(svg_size); > image.fill(Qt::transparent); > > QPainter painter(&image); > painter.setRenderHint(QPainter::Antialiasing); > painter.setRenderHint(QPainter::SmoothPixmapTransform); > painter.setRenderHint(QPainter::TextAntialiasing); > > QRect frame(QPoint(), image.size()); > std::auto_ptr<QGraphicsScene> scene(new QGraphicsScene(frame)); > QGraphicsWebView *web_view = new QGraphicsWebView(); > web_view->setGeometry(frame); > web_view->setContent(svg_byte_array, svg_mime_type); > web_view->setOpacity(0.001); // work around bug in web view 4.8 > (draws white background without this) > scene->addItem(web_view); > > scene->render(&painter); > > return image; > } > . > -- Martin Holmes University of Victoria Humanities Computing and Media Centre (mhol...@uvic.ca) _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest