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();
}
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();
}