View Full Version : Unsetting transparency

Pavel Abrosimov
8th October 2009, 13:05

The application I am trying to develop is required to have the window as the main output of the information. This window needs to be resizable and have an ability to be transparent.

With resizing there is no problem. But the second feature has an issue.

I am setting the window next way:

MainOutput:: MainOutput(QWidget *parent)
: QWidget(parent, Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint)

void MainOutput::configureWindow()
resize(myConfig.wCoordinate(),myConfig.hCoordinate ());
move(myConfig.xCoordinate(),myConfig.yCoordinate() );
setAttribute(Qt::WA_TranslucentBackground, myConfig.IsTransparent());

The problem is that if initially window was not transparent – the setting it to be such works as I am passing

setAttribute(Qt::WA_TranslucentBackground, true);

But when I am trying to unset transparency with

setAttribute(Qt::WA_TranslucentBackground, false);

it doesn’t make any change.

I am using QT 4.5 under Ms Windows XP with MiGW.

Is there anything I am doing wrong?

8th October 2009, 13:09
You can also use:

void setWindowOpacity ( qreal level );

Pavel Abrosimov
8th October 2009, 13:14
Thank you. I will try.

setWindowOpacity(qreal num);
makes the window AND what is inside to be transparent.
A apologize I didn't mention that the window has text on it. And text required to be visible all the time. It is just the window containing it needs to be transparent or not.