[英]Making a window a desktop in XLib/Qt
I am trying to write a simple program to act as my desktop background in Qt, I have made it all work fine apart from making it a Desktop Widget. 我正在尝试编写一个简单的程序来充当Qt的桌面背景,除了使其成为Desktop Widget之外,我已经使其全部正常工作。 I have no idea on how to do this, I don't mind using XLib or Qt for doing this, but if anyone has some suggestions I would be very happy.
我不知道如何执行此操作,我不介意使用XLib或Qt进行此操作,但是如果有人提出建议,我将非常高兴。
I have created a simple example that will fill the desktop background white. 我创建了一个简单的示例,它将填充桌面背景白色。 It is easy to make it draw an image.
绘制图像很容易。
class DesktopWidget : public QWidget
{
Q_OBJECT
public:
DesktopWidget()
{
setAttribute(Qt::WA_X11NetWmWindowTypeDesktop);
resize(QApplication::desktop()->size());
}
protected:
void paintEvent(QPaintEvent*)
{
QPainter painter(this);
painter.fillRect(geometry(), Qt::white);
}
};
The problem with this solution is that it completely paints over everything that your desktop environment draws in the background (including icons, plasmoids,...). 该解决方案的问题在于,它完全覆盖了桌面环境在后台绘制的所有内容(包括图标,等离子体...)。
If you just want to set a new background image programmatically, I would check if your DE has an API for that. 如果您只是想以编程方式设置新的背景图片,我将检查您的DE是否具有用于此目的的API。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.