Translucent background - repaint issue Mac
-
When a patch gets and added and removed it generally means that it breaks something while trying to fix something else
-
Yes you can but your exact use case triggers that bug. One things you can do however is to add information on the current bug reports (also vote for it).
-
You already are using it, but why did you disable the background auto fill ?
-
I the same problem on Mac when moving from Qt4 to Qt5. I could reproduce it with different projects or code examples. I fixed it by adding this code to my application:
@
void MyTransparentWindow::paintEvent( QPaintEvent * /event/ )
{
QPainter p( this );// Qt5 fail to give us a clear backbuffer... p.setCompositionMode( QPainter::CompositionMode_Clear ); p.fillRect( 0, 0, width(), height(), QColor( 0, 0, 0, 0 ) ); p.setCompositionMode( QPainter::CompositionMode_SourceOver ); // end
...
}
@This fixed the problem for me when using Qt5.1.1, I haven't check if it's actually fixed in Qt5.2+.
-
sandy.martel
THANK YOUI experimented earlier with fill Qt::transparent but without composition mode. Setting (only)
@
void TransWidget::paintEvent( QPaintEvent * /event/ )
{
QPainter p( this );p.setCompositionMode( QPainter::CompositionMode_Clear ); p.fillRect( this->rect(), Qt::transparent );
}
@resolves problem:
Qt 5.2.1 - MacOSX 10.9.2
-
Very nice trick !
Thanks for sharing :)
-
This topic is old, but i face with same problem and tricks won't help me. Im using Qt 5.5
So i found solution in Telegram app source code.- Set attributes and window flags
m_widget->setWindowFlags(Qt::FramelessWindowHint | Qt::BypassWindowManagerHint | Qt::Tool | Qt::NoDropShadowWindowHint);
m_widget->setAttribute(Qt::WA_NoSystemBackground, true);
m_widget->setAttribute(Qt::WA_TranslucentBackground, true); - In paint event
QPainter::CompositionMode m = painter.compositionMode();
painter.setCompositionMode(QPainter::CompositionMode_Source);
painter.setOpacity(0.4);
painter.fillRect(w->rect(), Qt::black);
painter.setCompositionMode(m);
- Set attributes and window flags