ultralight-ux / Ultralight

Lightweight, high-performance HTML renderer for game and app developers.
https://ultralig.ht
4.69k stars 197 forks source link

How to use this library, just like using webview? #106

Open luoshuai5 opened 5 years ago

luoshuai5 commented 5 years ago

I hope this library can support mixed development, such as MFC, Qt.

niutech commented 5 years ago

I would also like to know how to make a drop-in replacement for QWebView. Should I import Ultralight as a third-party library and make a custom Qt widget instantiating a View? Or should I extend the QWebView class?

niutech commented 4 years ago

OK, I managed to embed Ultraview as a QWidget in Qt5 app on Windows 10 by using createWindowContainer() method:

app = App::Create();
window = Window::Create(app->main_monitor(), WINDOW_WIDTH, WINDOW_HEIGHT, false, 0);
app->set_window(*window.get());
overlay = Overlay::Create(*window.get(), 0, 0, 0, 0);
...
unsigned long winId = (unsigned long) window->native_handle();
QWindow* qWindow = QWindow::fromWinId(winId);
QWidget* qWidget = createWindowContainer(qWindow);
setCentralWidget(qWidget);

Here is the screenshot: ultralight-qt

niutech commented 3 years ago

I made a brand new repo Qt Ultralight Browser which showcases QUltralight widget in Qt app.