-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
33 lines (30 loc) · 902 Bytes
/
mainwindow.cpp
File metadata and controls
33 lines (30 loc) · 902 Bytes
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
#include <QtWidgets>
#include <QtWebKitWidgets>
#include "mainwindow.h"
MainWindow::MainWindow()
{
centralWidget = new Gmap(this);
setCentralWidget(centralWidget);
this->setMap();
}
void MainWindow::setMap()
{
QString fileName = ":/new/map/gmap.html";
if(!QFile(fileName).exists()) {
QMessageBox::critical(this, tr("Attention !!"),
"File not found: " + fileName);
return;
} else {
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly)) {
QMessageBox::information(this, tr("Sorry .."),
"Cannot Set Map ..\n" + file.errorString());
return;
}
QTextStream out(&file);
QString output = out.readAll();
// display contents
centralWidget->webView->setHtml(output);
centralWidget->webView->page()->mainFrame()->evaluateJavaScript("initMarker();");
}
}