Problem in making QWidget background transparent by setting WA_ContentsPropagated attribute.
-
Hi,
I am loading a URL using QWebView(inherits QWidget), I would like to make the background of this widget transparent. As per the documentation at http://doc.qt.nokia.com/qq/qq16-background.html, I tried to set the attribute WA_ContentsPropagated for this widget but it is not working.
Sample code :-
@
QWebView* webView = new QWebView();
webView->settings()->setAttribute(QWebSettings::PluginsEnabled, true);
webView->load(QUrl("http://s0.2mdn.net/2281014/PID_1862071_YvaExpandableMaster.swf"));
webView->setAttribute(Qt::WidgetAttribute::WA_ContentsPropagated);webView->setGeometry(100,100,1000, 500);
webView->show();
@Please advice where I am going wrong.
[EDIT: code formatting, please wrap in @-tags, Volker]
-
I am amazed to see that in this world of qt developers does nodody know the answer for this.....
or atleast is it possible to give particular color and all that colored background will become transparent. -
You did wait about a day - patience is a virtue!
We have holiday time in many parts of the world, so people are not in front of their workstations and answer developer's questions but sit together with their families.
Additionally, whining at your fellow developers is not very likely to make them eager to help you.
-
Hi,
I have given a try by setting QPalette for this widget. Since as per Qt doc this is the basic interface for any bg, foregrond color related change.
while creating the Palette I have specifed brush as no brush and color as QColor which has alpha value as 0. Neverthless my widget is not becoming transparent but it is getting totally black.Below mention is the code.
@
QPalette pal;
QBrush brush(Qt::NoBrush);
QColor color(Qt::transparent);
pal.setBrush(QPalette::Window,brush);
pallete.setColor(QPalette::Window,color);
QWidget window;
window.setPalette(pal);
window.setGeometry(10,10,250,250);
window.show();
@ -
Maybe this "link":http://doc.qt.nokia.com/qq/qq16-background.html is helpful.
-
Thanks for suggestion. I have gone through this link multiple times , and got an idea that in Qt we can control color behaviour using QPalette, but not helping me . :(
-
Maybe "this":http://developer.qt.nokia.com/forums/viewthread/1107 one ? Just search this site for "transparent background". There are plenty threads about this.
-
Hi Hobby,
Hats off to you man , I am able to achieve bg transparency by just three lines of code , mentioned in the link suggetsed by you.
Thank you very much for your timely help.
Regards
Ashish -
Glad I could help. The credit should go to the guy who actually provided the solution, I just remembered reading something about this a while ago.
-
HI ,
I have just tested my transparency code in Suse Linux, which is having
Qt 4.6.3 run time libraries.
I am getting totally black window instead of transparent window and on commnad promptI am getting message as "QGtkStyle was unable to detect the current GTK+ theme."
Please help what is going wrong on Linux.
Am I missing some X11 related display driver on Linux machine