diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-03-07 23:41:37 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-03-07 23:41:37 +0530 |
| commit | 4ce5d59c41d4217f02e6f84c6e531fbc4ee20122 (patch) | |
| tree | 6821ee74a348c65724bd83ee8fecf7fb43e295b7 /src | |
| parent | d7b0739cca80d0af95367e801972d10e3ea859db (diff) | |
| download | null-browser-4ce5d59c41d4217f02e6f84c6e531fbc4ee20122.tar.gz null-browser-4ce5d59c41d4217f02e6f84c6e531fbc4ee20122.zip | |
Simple qtwebengine view
Diffstat (limited to '')
| -rw-r--r-- | src/main.cpp | 8 | ||||
| -rw-r--r-- | src/play.cpp.old | 62 |
2 files changed, 66 insertions, 4 deletions
diff --git a/src/main.cpp b/src/main.cpp index 275bed6..03bc7c2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,12 +6,12 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); QWidget mainWindow; - mainWindow.setWindowTitle("Qt6 WebEngine"); + mainWindow.setWindowTitle("web-browser"); - QVBoxLayout *layout = new QVBoxLayout(&mainWindow); - QWebEngineView *view = new QWebEngineView(); + auto layout = new QVBoxLayout(&mainWindow); + auto view = new QWebEngineView(); view->setFixedSize(400, 400); - view->setUrl(QUrl("https://www.qt.io")); + view->setUrl(QUrl("https://ediblemonad.dev")); layout->addWidget(view); mainWindow.show(); diff --git a/src/play.cpp.old b/src/play.cpp.old new file mode 100644 index 0000000..4a61043 --- /dev/null +++ b/src/play.cpp.old @@ -0,0 +1,62 @@ +#include <QApplication> +#include <QVBoxLayout> +#include <QWidget> +#include <cef_app.h> +#include <cef_browser.h> +#include <cef_client.h> +#include <internal/cef_string.h> +#include <iostream> +#include <ostream> + +class CEFWidget : public QWidget { +public: + explicit CEFWidget(QWidget *parent = nullptr) : QWidget(parent) { + setFixedSize(400, 400); + + // TODO: Args + char *argv[] = {}; + int argc = 0; + + std::cout << "ficlk" << std::endl; + + // Create browser + CefWindowInfo window_info; + CefBrowserSettings browser_settings; + window_info.SetAsChild(winId(), {0, 0, 400, 400}); + CefBrowserHost::CreateBrowser(window_info, nullptr, "https://www.qt.io", + browser_settings, nullptr, nullptr); + } + + ~CEFWidget() { CefShutdown(); } +}; + +int main(int argc, char *argv[]) { + CefMainArgs main_args(argc, argv); + CefRefPtr<CefApp> cefApp; + int exit_code = CefExecuteProcess(main_args, cefApp, nullptr); + if (exit_code >= 0) { + return exit_code; + } + + CefMainArgs args(argc, argv); + CefSettings settings; + CefString(&settings.resources_dir_path) + .FromWString(L"/home/imsohexy/dev/projects/web-browser/build/lib/"); + CefString(&settings.locales_dir_path) + .FromWString( + L"/home/imsohexy/dev/projects/web-browser/build/lib/locales/"); + CefString(&settings.root_cache_path) + .FromWString(L"/home/imsohexy/dev/projects/web-browser/.cache/cef"); + settings.no_sandbox = true; + settings.pack_loading_disabled = true; + CefInitialize(args, settings, nullptr, nullptr); + + QApplication app(argc, argv); + QWidget mainWindow; + mainWindow.setWindowTitle("web-browser"); + QVBoxLayout layout(&mainWindow); + // CEFWidget cefWidget(&mainWindow); + // layout.addWidget(&cefWidget); + mainWindow.show(); + return app.exec(); +} |
