Qt+Cef integration on Linux
-
Actually, I've managed to make it work.
Just in case, if someone will need it in future:GtkWidget* gtkWin = gtk_window_new(GTK_WINDOW_TOPLEVEL); GtkWidget* parentView = gtk_vbox_new(FALSE, 0); GtkContainer* container = (GTK_CONTAINER(gtkWin)); gtk_container_add(container, parentView); gtk_window_set_position(GTK_WINDOW(gtkWin), GTK_WIN_POS_CENTER); gtk_widget_show_all(GTK_WIDGET(gtkWin)); GdkWindow* w = gtk_widget_get_window(parentView); XID t = gdk_x11_drawable_get_xid(w); WId wid = (WId) t; QWindow* win = QWindow::fromWinId(wid); setLayout(new QGridLayout()); QWidget* widget = QWidget::createWindowContainer(win); this->layout()->addWidget(widget); info.SetAsChild(parentView);
Basically, I've created my own GTK window, passed the reference on this window to CEF, and placed it into Qt widget using QWindow::fromWinId().
-
So would it be fair to conclude that it really
wants a gtk windows handle and not what ever comes out of
winId() ? -
So would it be fair to conclude that it really
wants a gtk windows handle and not what ever comes out of
winId() ? -
@gepgep
Not that i have stumbled upon.
Have you asked on the forum ?
http://magpcss.org/ceforum/You cannot use http://doc.qt.io/qt-5/qtwebengine-index.html
or webkit ? -
@gepgep
Not that i have stumbled upon.
Have you asked on the forum ?
http://magpcss.org/ceforum/You cannot use http://doc.qt.io/qt-5/qtwebengine-index.html
or webkit ?@mrjj i am wondering if it can be done with cef due to (my) project restrictions ..
I have found several git repos with qt+cef, but only for windows. Also i managed to combine gtk with cef successfully, but i cant find anything about qt+cef@linux (maybe because qt+gtk is not a happy combination?). The code snippet from @antofik does not build (gtkwidget with qwidget is it even possible) or i am missing something? -
@mrjj i am wondering if it can be done with cef due to (my) project restrictions ..
I have found several git repos with qt+cef, but only for windows. Also i managed to combine gtk with cef successfully, but i cant find anything about qt+cef@linux (maybe because qt+gtk is not a happy combination?). The code snippet from @antofik does not build (gtkwidget with qwidget is it even possible) or i am missing something?@gepgep
Well mixing Gtk and Qt is pretty rare use case as far as I know. Both being Widgets libraries.
And there is always the issue of the event loop.
So as far as integration it will not be funny.@antofik sample wraps a gtk window using native Gtk calls +Qt and is apparently supported by
createWindowContainer so in this case it works.I have not seen much info about this. sorry.
-
@gepgep
Well mixing Gtk and Qt is pretty rare use case as far as I know. Both being Widgets libraries.
And there is always the issue of the event loop.
So as far as integration it will not be funny.@antofik sample wraps a gtk window using native Gtk calls +Qt and is apparently supported by
createWindowContainer so in this case it works.I have not seen much info about this. sorry.
-
@gepgep
Hi
Just as a note.
Webkit been revived
https://forum.qt.io/topic/76739/webkit-status-2017So you might be able to use that?
-
Actually, I've managed to make it work.
Just in case, if someone will need it in future:GtkWidget* gtkWin = gtk_window_new(GTK_WINDOW_TOPLEVEL); GtkWidget* parentView = gtk_vbox_new(FALSE, 0); GtkContainer* container = (GTK_CONTAINER(gtkWin)); gtk_container_add(container, parentView); gtk_window_set_position(GTK_WINDOW(gtkWin), GTK_WIN_POS_CENTER); gtk_widget_show_all(GTK_WIDGET(gtkWin)); GdkWindow* w = gtk_widget_get_window(parentView); XID t = gdk_x11_drawable_get_xid(w); WId wid = (WId) t; QWindow* win = QWindow::fromWinId(wid); setLayout(new QGridLayout()); QWidget* widget = QWidget::createWindowContainer(win); this->layout()->addWidget(widget); info.SetAsChild(parentView);
Basically, I've created my own GTK window, passed the reference on this window to CEF, and placed it into Qt widget using QWindow::fromWinId().
@antofik
Dear antofix,
Could you send me a complete example. I'm try the method but still not working with qt 5.5thanks