【发布时间】:2017-05-16 21:37:23
【问题描述】:
我的 Qt 应用程序应该将 JPEG 图像显示到 HDMI 监视器。当我在我的 Linux 桌面环境中运行应用程序时,图像会正确显示。
但是,当我在 LinuxFB 下的嵌入式 Linux 环境中运行此应用程序时,图像周围有大量绿色。
我的 1080p 显示器上的 NTSC (720x480) 彩条。
我的应用程序是用 QLabel 而不是 QWidget 编写的,并且没有任何活动窗口。我尝试了许多解决方案,主要是使用 QPainter,但到目前为止,背景外观没有任何改变。
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();
}
应用程序执行如下
./my-Qt-application -qws -nomouse -display LinuxFb:/dev/fb1
我认为这与 Linux 帧缓冲区本身没有任何关系,因为绿色背景仅在我运行 Qt 应用程序时出现。
假设绿色背景来自 Qt,我该怎么做才能将其关闭(或使其透明)?
【问题讨论】:
-
谢谢,这是一个错字。我在编辑中更正了它。
标签: c++ qt embedded-linux framebuffer