File tree 7 files changed +107
-0
lines changed
7 files changed +107
-0
lines changed Original file line number Diff line number Diff line change
1
+ bin
Original file line number Diff line number Diff line change
1
+ QT += core gui webenginewidgets
2
+
3
+ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
4
+ CONFIG += c++20
5
+
6
+ SOURCES += \
7
+ main.cpp \
8
+ mainwindow.cpp
9
+
10
+ HEADERS += \
11
+ mainwindow.h
12
+
13
+ Release:DESTDIR = release
14
+ Release:OBJECTS_DIR = release/.obj
15
+
16
+ Debug:DESTDIR = debug
17
+ Debug:OBJECTS_DIR = debug/.obj
18
+
19
+ # # Default rules for deployment.
20
+ # qnx: target.path = /tmp/$${TARGET}/bin
21
+ # else: unix:!android: target.path = /opt/$${TARGET}/bin
22
+ # !isEmpty(target.path): INSTALLS += target
Original file line number Diff line number Diff line change
1
+ all :
2
+ mkdir -p bin
3
+ cd bin; qmake ..;
4
+ ${MAKE} -C bin
5
+
6
+ run : all
7
+ bin/HelloWolrd
8
+
9
+ clean :
10
+ rm -rf bin
Original file line number Diff line number Diff line change
1
+ # QtWebEngine Simple App
2
+
3
+ A simple app to test the power of the QtWebEngine (chromiun based)
4
+
5
+ ## Running
6
+ if you just want to build the project, make sure you have Qt < 5 and qmake installed and the GNUMake
7
+
8
+ then run:
9
+ ``` Shell
10
+ make all
11
+
12
+ ```
13
+ ===
14
+
15
+ for running directly use:
16
+ ``` Shell
17
+ make run
18
+ ```
19
+ ===
20
+ To clean the build
21
+ ``` Shell
22
+ make clean
23
+ ```
Original file line number Diff line number Diff line change
1
+ #include " mainwindow.h"
2
+
3
+ #include < QApplication>
4
+ #include < mainwindow.h>
5
+ #include < QtWebEngine/QtWebEngine>
6
+
7
+ int main (int argc, char *argv[])
8
+ {
9
+ QApplication a (argc, argv);
10
+ MainWindow w;
11
+ w.show ();
12
+ return a.exec ();
13
+ }
Original file line number Diff line number Diff line change
1
+ #include " mainwindow.h"
2
+ #include < iostream>
3
+
4
+ MainWindow::MainWindow (QWidget *parent) : QMainWindow(parent)
5
+ {
6
+ this ->resize (800 , 800 );
7
+ view = new QWebEngineView (this );
8
+ this ->setCentralWidget (view);
9
+
10
+ QUrl myurl (" https://github.com" );
11
+ view->load (myurl);
12
+ view->page ()->runJavaScript (" navigator.userAgent;" , [=](const QVariant &v){
13
+ QString res = v.toString ();
14
+ std::cout << " UserAgent is: " << res.toStdString () << " \n " ;
15
+ });
16
+ std::cout << " Hello wolrd\n " ;
17
+ // QObject::connect (p, &QPushButton::clicked, [=]() {
18
+ // std::cout << "Hello wolrd button clicked\n";
19
+ // });
20
+ }
Original file line number Diff line number Diff line change
1
+ #ifndef MAINWINDOW_H
2
+ #define MAINWINDOW_H
3
+
4
+ #include < QMainWindow>
5
+ #include < QPushButton>
6
+ #include < QWebEngineView>
7
+
8
+ class MainWindow : public QMainWindow
9
+ {
10
+ Q_OBJECT
11
+ public:
12
+ explicit MainWindow (QWidget *parent = nullptr );
13
+ private:
14
+ QWebEngineView *view;
15
+
16
+ };
17
+
18
+ #endif // MAINWINDOW_H
You can’t perform that action at this time.
0 commit comments