Qt6 topics merged with General

Qt frameless windows paint problem on Ubuntu 14

  • Expected Result:
    Expected Graphics
    Actual Result

    Hi everyone, I've been encountering a strange issue with a frameless tool in QT on Ubuntu 14.04 (VM guest admittedly but replicable over physical machine).
    Basically I have this makeshift menu held inside a frameless window with rounded clipped edges. To get this to work on windows and mac I have set it up like this:
    in the constructor I am setting these flags

      this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowStaysOnTopHint);

    and in the overridden paint event:

     QPainter painter(this);
        QPainterPath rounded_rect;
        rounded_rect.addRoundedRect(0, 0, originalRectangle.width(), originalRectangle.height(), roundness, roundness);
        QRegion testRegion = painter.clipRegion();
    #ifdef __APPLE__
    #elif WIN32
    #elif __unix

    I thought the CompositionMode would be the same between Linux and Mac, so that may be the issue... I have tried a few of the others but it doesn't seem to be the issue, as the ImageComposer example seems to work alright on my system.
    What happens is this: when the window is first shown, it appears with only the desktop (or other background application) painted on it... After clicking on it it wakes up and gets drawn properly.

    I tried manually calling Update / UpdateGeometry /Repaint etcetera, to no avail.
    When I click on this dirty drawn window it immediately calls a paint operation and the window graphics get corrected.

    Am I facing a late draw operation or a problem in concept? Or fundamental problem with frameless windows on ubuntu?

    Thanks in advance,
    Paolo Manili

  • Moderators

    Hello Paolo,
    At a first glance it looks okay, could you prepare a MWE that can be tested as a stand-alone application?
    I'd also like to point out that Qt already defines the OS macros, so you don't need to do it yourself, they are Q_OS_UNIX, Q_OS_WIN32 and so on. Also why are you using different composition modes for different platforms, this doesn't seem quite consistent? And one more note, are you sure you're not supposed to use the Qt::WA_NoSystemBackground attribute for your widget as well?

    Kind regards.

Log in to reply