Qt frameless windows paint problem on Ubuntu 14
-
Expected Result:
Expected Graphics
Actual ResultHi 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 flagsthis->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 -
@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 areQ_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 theQt::WA_NoSystemBackground
attribute for your widget as well?Kind regards.