Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt frameless windows paint problem on Ubuntu 14
Forum Updated to NodeBB v4.3 + New Features

Qt frameless windows paint problem on Ubuntu 14

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 925 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • paolomaniliP Offline
    paolomaniliP Offline
    paolomanili
    wrote on last edited by
    #1

    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);
        painter.save();
        painter.setRenderHint(QPainter::Antialiasing);
        painter.setCompositionMode(QPainter::CompositionMode_Clear);
        painter.setPen(backgroundColor);
    
        QPainterPath rounded_rect;
        rounded_rect.addRoundedRect(0, 0, originalRectangle.width(), originalRectangle.height(), roundness, roundness);
        painter.setClipPath(rounded_rect);
        painter.setOpacity(opacity);
        QRegion testRegion = painter.clipRegion();
    #ifdef __APPLE__
        painter.setCompositionMode(QPainter::CompositionMode_Source);
    #elif WIN32
        painter.setCompositionMode(QPainter::CompositionMode_DestinationOver);
    #elif __unix
        painter.setCompositionMode(QPainter::CompositionMode_Source);
    #endif
        painter.fillPath(rounded_rect,QBrush(backgroundColor));
    
        this->setMask(testRegion);
    

    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

    1 Reply Last reply
    0
    • kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      @paolomanili
      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.

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved