PDA

View Full Version : Transparent Window Background QtConfig settings?



MercyYuen
10th October 2012, 17:34
I found this code example on http://www.codeprogress.com/cpp/libraries/qt/showQtExample.php?key=QMainWindowTransparentBg&index=191

It's supposed to create a QT window and have it be transparent so that the desktop will show through it.

When I run the code, the background simply shows up as black instead of transparent.

The webpage notes that if the QT GUI styling does not work as expected, check your qtconfig settings. But I'm not sure which settings I'm supposed to modify.

Has anyone run into this before?


#include <QtGui>

int main(int argc, char *argv[])
{
QApplication app(argc, argv);

QMainWindow *window = new QMainWindow();
window->setAttribute( Qt::WA_TranslucentBackground );
window->setWindowTitle(QString::fromUtf8("QMainWindow Transparent Background"));
window->resize(800, 250);

QLCDNumber *number = new QLCDNumber();
number->setFixedSize(800, 245);
number->setDigitCount(12);
number->display(QTime::currentTime().toString(QString("hh:mm:ss.zzz")));


window->setCentralWidget(number);
window->show();

return app.exec();
}

Ashkan_s
10th October 2012, 20:03
if you are using Windows, add this line after line 8


window->setWindowFlags(Qt::FramelessWindowHint);

MercyYuen
11th October 2012, 00:48
I'm using ubuntu. I have tried what you suggested, and it did not resolve my issue. Any other ideas?

wagmare
11th October 2012, 12:43
check which manager is running in ur ubuntu ..
* Metacity
use gconf-editor->apps->metacity->enablecompositing_manager.
*compiz
use compiz-manager and increase the transparency .

u can check it in ur linux process list .. ps -ax

MercyYuen
11th October 2012, 16:30
Thank you wagmare! That solved my problem! I had to enable compositing on metacity

https://help.ubuntu.com/community/Metacity