Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I need to develop an application for
Windows
,
Linux
and
Mac
. To not have to write all the window cruft myself I chose to use
Qt5
(over
wxWidgets
, because the latter ship no precompiled binaries). I have a
GTK
Widget (of
Cef
) which I now need to embed, but sadly have no idea how.
There seems to have been
QX11EmbedContainer
in previous versions of
Qt
, but it is not present anymore and also I am not sure this works, when there is a switch to
Weyland
.
–
QMainWindow* main_window = new QMainWindow;
QX11EmbedContainer* container = new QX11EmbedContainer;
main_window->setCentralWidget(container);
//gtk code
GtkWidget* window;
GtkWidget* button;
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
button = gtk_button_new ();
gtk_widget_show (button);
gtk_container_add (GTK_CONTAINER (window), button);
gtk_widget_show(window);
XID id = GDK_WINDOW_XWINDOW (GTK_WIDGET(window)->window);
container->embedClient(id);
you can use QX11EmbedContainer class on Qt4.
–
It's been 7 years, but I've dealt with this before. Here's what I found1:
I found a way to properly embed CEF inside a Qt window: embedding it inside an empty QWindow instead of a QWidget. There are some caveats, though:
To add the CEF window into a QWidget layout, you will need to use QWidget::createWindowContainer()
An empty QWindow doesn't render anything -- not even a background. So, you might need to use a QBackingStore to make it render something when CEF isn't embedded -- see the Raster Window example for some reference.
You might need to use the winId from before you add the QWindow into your widget's layout.
I highly recommend anyone still trying this to take a look at the entire thread1. QtWebkit is not longer an acceptable solution, while CEF centainly is.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.