blob: c8d460da52231799c5bf733b8e3d0bb4f7928613 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#include <QtGui>
#include <QtWebKit>
#include <QFile> //needed for In/Output
#include "webkittest.h"
webkitTest::webkitTest(QWidget *parent, QUrl & url)
: QWidget(parent)
{
ui.setupUi(this);
this->url = url;
//define starting page
ui.webView->load(this->url); //QUrl("http://132.230.4.3/webkitTest.html")
ui.webView->show();
//enable JavaScript access to qt objects
QObject::connect(ui.webView->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(addJSObject()));
//remove the window decoration
Qt::WindowFlags flags = Qt::SplashScreen;
this->setWindowFlags(flags);
//set form to fullscreen
this->showFullScreen();
//set webView to the same size as the form
ui.webView->resize(this->size());
}
//enable JavaScript access to qt objects
void webkitTest::addJSObject() {
ui.webView->page()->mainFrame()->addToJavaScriptWindowObject(QString("webkitTest"), this);
}
void webkitTest::writeText(QString text){
QFile file("out.txt");
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
return;
QTextStream out(&file);
out << text << "\n";
}
/*
void webkitTest::setQApplication(const QApplication & app){
}
*/
void webkitTest::setUrl(QUrl & url){
this->url = url;
}
webkitTest::~webkitTest()
{
}
|