Reputation: 217
My Qt application is supposed to display a JPEG image to an HDMI monitor. When I run the application on my Linux desktop environment, the image is displayed correctly.
However, when I run this application in an embedded Linux environment under LinuxFB, there is a large amount of green surrounding the image.
NTSC (720x480) color bars on my 1080p monitor.
My application was written with QLabel instead of QWidget, and does not have any active window. I have attempted a number of solutions, mostly using QPainter, but so far nothing has made a difference to background appearance.
int main (int argc, char *argv[])
{
QApplication app(argc, argv);
// Set the app palette to be transparent
app.setPalette(QPalette(Qt::transparent));
QPixmap input ("test.jpg");
QImage image(input.size(), QImage::Format_ARGB32_Premultiplied);
// Try to fill the QImage to be transparent
image.fill(Qt::transparent);
QPainter p(&image);
// Try a few things to get the painter background to be transparent
p.setOpacity(0.5); // 0 is invisible, 1 is opaque
p.setBackgroundMode(Qt::TransparentMode);
p.setBackground(Qt::transparent);
p.setBrush(Qt::transparent);
p.drawPixmap(0,0,input);
p.end();
QPixmap output = QPixmap::fromImage(image);
QLabel label (0, Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
// Set the style sheet background color as transparent as well
label.setStyleSheet("background-color: transparent;");
//label.setStyleSheet("background-color: rgba(255,255,255,0);");
label.setPixmap(output);
label.setScaledContents(true);
label.show();
return app.exec();
}
The application is executed with the following
./my-Qt-application -qws -nomouse -display LinuxFb:/dev/fb1
I do not believe this has anything to do with the Linux frame buffer itself because the green background is only present when I am running a Qt application.
Assuming the green background is coming from Qt, what can I do to turn it off (or make it transparent)?
Upvotes: 2
Views: 1080
Reputation: 982
The green background is coming from QWSServer. You can change it by using QWSServer::setBackground().
The origin of the green background is still Qt, but QWSServer
doesn't exist anymore. I'd suggest using a fullscreen QWidget
as a background. You can change to background color of the QWidget
with a simple stylesheet containing background-color: black;
.
Upvotes: 1
Reputation: 98485
You've done nothing to scale the label properly. The green background is where your label isn't - it's probably the default contents of the framebuffer. Fill the entire screen and you won't have that problem.
Upvotes: 0