Files
racket-webview/rktwebview_qt/rktwebview_test.cpp
2026-03-26 12:08:55 +01:00

55 lines
1.1 KiB
C++

#include "rktwebview.h"
#include <string>
#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif
#include "utils.h"
int main(int argc, char *argv[])
{
std::string me = argv[0];
std::string loc = basedir(me);
#ifdef _WIN32
std::string prg = loc + "\\rktwebview_prg.exe";
SetDllDirectoryA("C:\\Qt\\6.10.2\\msvc2022_64\\bin");
#else
std::string prg = loc + "/rktwebview_prg";
#endif
#ifdef _WIN32
{
std::string e = std::string("RKT_WEBVIEW_PRG=") + prg;
_putenv(e.c_str());
}
#else
setenv("RKT_WEBVIEW_PRG", prg.c_str(), true);
setenv("LD_LIBRARY_PATH", loc.c_str(), true);
#endif
int context = rkt_webview_new_context("", nullptr);
int wv = rkt_webview_create(context, 0);
rkt_webview_move(wv, 100, 200);
rkt_webview_resize(wv, 800, 600);
rkt_webview_set_url(wv, "https://wikipedia.org");
while(rkt_webview_events_waiting() > 0) {
rkt_data_t *d = rkt_webview_get_event();
rkt_webview_free_data(d);
}
#ifdef _WIN32
Sleep(10);
#else
sleep(10);
#endif
rkt_webview_close(wv);
rkt_webview_cleanup();
}