开发者

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. 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开发者_Go百科 very happy.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜