Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Do not automatically erase background on QWidget paintEvent (OSX)



  • Hi,

    When I create my widget, I do this:

    setBackgroundRole(QPalette::Base);
    setAutoFillBackground(false);
    setAttribute(Qt::WA_OpaquePaintEvent);
    

    which stops Qt from erasing the background on a paintEVent. It works perfectly on Windows and Linux. Under OSX, it seems the

    setAttribute(Qt::WA_OpaquePaintEvent);
    

    doesn't work. The widget gets erased on every paint event.

    Under Windows and Linux, if I remove the setAttribute(Qt::WA_OpaquePaintEvent); I get the same drawing as OSX with that call.

    Is this a known issue, or am I missing something under OSX?

    Run 5.14.1 on all platforms.

    Gerald


  • Lifetime Qt Champion

    Hi,

    What version of macOS ?
    Can you provide a minimal compilable example that shows that behavior ?



  • @SGaist Catalina. Is there a minimal sample I can start from? I pretty new to Qt, moving from wxWidgets, so I'm not sure what the protocol is here.

    Gerald


  • Lifetime Qt Champion

    @GeraldBrandt
    Hi
    @SGaist
    asks for a small example that shows the issue that he can just download it and run it and see
    if its easy to reproduce on his Mac.

    If we have to construct something we can run from code pieces we risk debugging something else
    so what we are after is a default GUI project with just enough code to see this.

    We cant upload zip file here so use online service and post the link.

    if its really is easy to recreate than state how to fast get it.

    Like "add a plain QWidget to the MainForm and apply the lines to it."



  • @mrjj I was just checking. As I mentioned, I come from wxWidgets, and they had a minimal sample they wanted everyone to use as a starting point.

    Gerald


  • Lifetime Qt Champion

    You can start from the default widget project template with Qt Creator.


Log in to reply