Draw in QDesktopWidget (Desktop-Background)
-
@mrjj Thanks for your quick reply, as you can see below, yes desktop() the static function from QApplication
QDesktopWidget *QApplication::desktop() Returns the desktop widget (also called the root window). The desktop may be composed of multiple screens, so it would be incorrect, for example, to attempt to center some widget in the desktop's geometry. QDesktopWidget has various functions for obtaining useful geometries upon the desktop, such as QDesktopWidget::screenGeometry() and QDesktopWidget::availableGeometry(). On X11, it is also possible to draw on the desktop.
So I thought it would be a good place for drawn something. "On X11, it is also possible to draw on the desktop."
Ok so you subclassed QDesktopWidget ?
Hmm yes, . "On X11, it is also possible to draw on the desktop." does sounds like it works on linux.
Did you try to give it a paintevent ?
-
Okay, perhaps I was misunderstood. It's no longer an Qt3 application! So QPainter is not an option in Q5:
QWidget::paintEngine: Should no longer be called."Ok so you subclassed QDesktopWidget ?" You can see in my first code-block, that's all. I inherit from "QApplication", get the desktop and try to draw inside like in the code above. This isn't working, any idea? I need something to cover the desktop background. I thought the QDesktopWidget from QApplication was just the thing, unfortunately no.
-
Okay, perhaps I was misunderstood. It's no longer an Qt3 application! So QPainter is not an option in Q5:
QWidget::paintEngine: Should no longer be called."Ok so you subclassed QDesktopWidget ?" You can see in my first code-block, that's all. I inherit from "QApplication", get the desktop and try to draw inside like in the code above. This isn't working, any idea? I need something to cover the desktop background. I thought the QDesktopWidget from QApplication was just the thing, unfortunately no.
@rsadowski
Well you may only use QPainter in the PaintEvent function unless drawing to an image.
So thats is most likely the reason for that error.Im not really sure how one would draw with it. Let me test and see if i can get a result.
-
Thanks for your efforts. This post describes what I want to do but I looks outdated for me:
Looking in https://doc.qt.io/qt-5/qx11info.html#appRootWindow it referents to https://doc.qt.io/qt-5/qapplication.html#desktop which sounds like "QApplication::desktop()" should give me the root widget (desktop).
-
I thought it should work, but it doesn't:
auto d = QWidget::createWindowContainer(QWindow::fromWinId(QX11Info::appRootWindow()));
but it only creates a new Window and not draw on the X11 desktop. I found an smeller post here:
https://lists.qt-project.org/pipermail/interest/2017-March/026304.html
-
I thought it should work, but it doesn't:
auto d = QWidget::createWindowContainer(QWindow::fromWinId(QX11Info::appRootWindow()));
but it only creates a new Window and not draw on the X11 desktop. I found an smeller post here:
https://lists.qt-project.org/pipermail/interest/2017-March/026304.html
@rsadowski
Hi
I tested various things i found on google and nothing did draw on the desktop. ( linux mint, Xfce )
I wonder if docs are wrong or it is indeed still possible. -
@rsadowski
Yes that would be a good idea. At least we need to change the docs if its really possible anymore
or there are requirements to the windows manager etc.
Its best if you include a sample so its easy to test for the developers. -
QDesktopWidget is deprecated - don't know if it's worth the trouble.
-
QDesktopWidget is deprecated - don't know if it's worth the trouble.
Oh Thanks, i missed "This class is obsolete." in the docs.
I agree it's unlikely it will be looked at.Also, so far none of the method one can google worked so it might not be possible anymore with
Qt alone.