[Interest] Problem with Embedding Translucent windows
Dave Butler
daveb at tanagerproductions.com
Mon Oct 14 21:04:47 CEST 2013
Hello list
I am trying to to embed a QWebview from one process into another process's
window. I want the background of the containing window to show through the
contained webview.
----- test.cpp BEGIN ----
#define EMBEDDING 1
#include <QtCore>
#include <QtGui>
#include <QtWebKit>
//#include "stdafx.h"
#include <QX11EmbedWidget>
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
#if EMBEDDING == 1
QX11EmbedWidget *parent = new QX11EmbedWidget();
#else
QWidget *parent = new QWidget();
#endif
parent->show();
QWebView *web = new QWebView(parent);
parent->setAttribute(Qt::WA_TranslucentBackground);
QWebPage *page = web->page();
QPalette palette = page->palette();
palette.setBrush(QPalette::Base, Qt::transparent);
page->setPalette(palette);
#if EMBEDDING == 1
parent->embedInto(atoi(argv[1]));
#endif
page->currentFrame()->documentElement().setInnerXml("text");
web->show();
parent->show();
return app.exec();
}
----- test.cpp END ----
----- test2.cpp BEGIN ----
#include <QtCore>
#include <QtGui>
#include <iostream>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget *parent = new QWidget();
parent->setStyleSheet("background-color: yellow;");
parent->show();
parent->move(100,100);
std::cout << "Winid: " << parent->winId() << "\n";
return app.exec();
}
----- test2.cpp END ----
I built these on Ubuntu 12.04 x86_64 with the following commands:
gcc test.cpp -I/usr/include/qt4/QtCore/ -I/usr/include/qt4/QtGui/
-I/usr/include/qt4/QtWebKit -I/usr/include/qt4/ -lQtCore -lQtGui
-lQtWebKit -o test.out
gcc test2.cpp -I/usr/include/qt4/QtCore/ -I/usr/include/qt4/QtGui/
-I/usr/include/qt4/QtWebKit -I/usr/include/qt4/ -lQtCore -lQtGui
-lQtWebKit -o test2.out
to run the code, first do `./test2.out` it should output a window ID, then
do `./test.out <winid>` where <winid> is the window id that is from the
test2.out output
If you don't have a compositing window manager running, you may have to
start xcompmgr
Instead of getting the result that I want, I just get a black square where
the background of the other application should show through....
To demonstrate that translucency works in non embedding situations, just
set EMBEDDING to 0 test.cpp
Please let me know if I am missing something or if there is a workaround.
Thanks
--Dave Butler
PS. I don't really know C/C++, just ported my PySide problem case over for
the benefit of this list. However, I should be able to Port ant C/C++
recommendations back to PySide
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20131014/66fdcdab/attachment.html>
More information about the Interest
mailing list