On Wednesday 17 December 2008 15:39, Dirk Stöcker wrote:
> I think this I tried and it failed. Together with multiple tries to set
> the stuff in QApplication screen handling.
Well you see, you're using QWebView, which is the QWidget container for
QWebKit. The widget and windowing system is not really needed at all here* -
you can just use plain old QWebPage which can render to an arbitrary
QPainter.
robert.
* not quite true - Qt needs to get its fonts etc from somewhere.
--- webkit-image.cpp.orig 2008-12-19 02:12:49.000000000 +0000
+++ webkit-image.cpp 2008-12-19 02:56:10.000000000 +0000
@@ -7,9 +7,11 @@
-I C:\Progra~1\Qt\include -L C:\Progra~1\Qt\lib
*/
#include <QtGui/QApplication>
+#include <QtGui/QPainter>
#include <QtCore/QFile>
#include <QtCore/QString>
-#include <QtWebKit/QWebView>
+#include <QtWebKit/QWebPage>
+#include <QtWebKit/QWebFrame>
/* using mingw to set binary mode */
#ifdef WIN32
@@ -26,18 +28,18 @@
{
Q_OBJECT
public:
- Save(QWebView *v) : view(v) {};
+ Save(QWebPage *p) : page(p) {};
public slots:
- void setGeometry(const QRect &r)
- {
- view->setGeometry(r);
- }
void loaded(bool ok)
{
if(ok)
{
- QImage im = QPixmap::grabWidget(view).toImage();
+ page->setViewportSize ( page->mainFrame()->contentsSize () );
+ QImage im ( page->viewportSize(), QImage::Format_ARGB32 );
+ QPainter painter ( & im );
+
+ page->mainFrame()->render ( & painter );
QFile f;
BINARYSTDOUT
@@ -55,7 +57,7 @@
void finish(void);
private:
- QWebView *view;
+ QWebPage * page;
};
#include "webkit-image.h"
@@ -67,13 +69,11 @@
QString url = QString(argv[1]);
QApplication a( argc, argv );
- QWebView *view = new QWebView();
- Save *s = new Save(view);
- view->resize(WIDTH,WIDTH);
+ QWebPage * page = new QWebPage();
+ Save * s = new Save(page);
- QObject::connect(view, SIGNAL(loadFinished(bool)), s, SLOT(loaded(bool)));
+ QObject::connect(page, SIGNAL(loadFinished(bool)), s, SLOT(loaded(bool)));
QObject::connect(s, SIGNAL(finish(void)), &a, SLOT(quit()));
- QObject::connect(view->page(), SIGNAL(geometryChangeRequested(const QRect &)), s, SLOT(setGeometry(const QRect &)));
- view->load(QUrl(url));
+ page->mainFrame()->load ( QUrl ( url ) );
return a.exec();
}
_______________________________________________
josm-dev mailing list
[email protected]
http://lists.openstreetmap.org/listinfo/josm-dev