-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
121 lines (103 loc) · 3.57 KB
/
main.cpp
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include <QtWidgets>
#include "yakarimmainwindow.h"
static void showHelp(QCommandLineParser &parser, const QString errorMessage = QString())
{
QString text;
QTextStream str(&text);
str << "<html><head/><body>";
if (!errorMessage.isEmpty())
str << "<p>" << errorMessage << "</p>";
str << "<pre>" << parser.helpText() << "</pre></body></html>";
QMessageBox box(errorMessage.isEmpty() ? QMessageBox::Information : QMessageBox::Warning,
QGuiApplication::applicationDisplayName(), text, QMessageBox::Ok);
box.setTextInteractionFlags(Qt::TextBrowserInteraction);
box.exec();
}
int main(int argc, char * argv[])
{
QApplication app(argc, argv);
QCommandLineParser commandLineParser;
commandLineParser.addPositionalArgument(QStringLiteral("url"),
QStringLiteral("The url to be loaded in the browser window."));
commandLineParser.process(app);
QStringList positionalArguments = commandLineParser.positionalArguments();
QUrl url;
if (positionalArguments.size() > 1) {
showHelp(commandLineParser, QStringLiteral("Too many arguments."));
return -1;
} else if (positionalArguments.size() == 1)
url = QUrl::fromUserInput(positionalArguments.at(0));
else
url = QUrl("http://www.afaagh.com");
if (!url.isValid()) {
showHelp(commandLineParser, QString("%1 is not a valid url.").arg(positionalArguments.at(0)));
return -1;
}
MainWindow browser(url);
browser.show();
return app.exec();
}
/*fancy browser sample
*#include <QtWidgets>
#include "mainwindow.h"
static void showHelp(QCommandLineParser &parser, const QString errorMessage = QString())
{
QString text;
QTextStream str(&text);
str << "<html><head/><body>";
if (!errorMessage.isEmpty())
str << "<p>" << errorMessage << "</p>";
str << "<pre>" << parser.helpText() << "</pre></body></html>";
QMessageBox box(errorMessage.isEmpty() ? QMessageBox::Information : QMessageBox::Warning,
QGuiApplication::applicationDisplayName(), text, QMessageBox::Ok);
box.setTextInteractionFlags(Qt::TextBrowserInteraction);
box.exec();
}
int main(int argc, char * argv[])
{
QApplication app(argc, argv);
QCommandLineParser commandLineParser;
commandLineParser.addPositionalArgument(QStringLiteral("url"),
QStringLiteral("The url to be loaded in the browser window."));
commandLineParser.process(app);
QStringList positionalArguments = commandLineParser.positionalArguments();
QUrl url;
if (positionalArguments.size() > 1) {
showHelp(commandLineParser, QStringLiteral("Too many arguments."));
return -1;
} else if (positionalArguments.size() == 1)
url = QUrl::fromUserInput(positionalArguments.at(0));
else
url = QUrl("http://www.qt-project.org");
if (!url.isValid()) {
showHelp(commandLineParser, QString("%1 is not a valid url.").arg(positionalArguments.at(0)));
return -1;
}
MainWindow browser(url);
browser.show();
return app.exec();
}
*/
/*#include <QApplication>
#include <QWebView>
int main (int argc, char *argv[])
{
QApplication yakarim(argc, argv);
QWebView yakarimView;
yakarimView.show();
yakarimView.load(QUrl("http://afaagh.com"));
return yakarim.exec();
}
maddahi 951118*/
/*http://www.bogotobogo.com/Qt/Qt5_WebKit_WebView_WebBrowser_QtCreator.php
#include <QApplication>
#include <QWebView>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWebView view;
view.show();
view.load(QUrl("http://google.com"));
return a.exec();
} *
**/