Bug 368048 - Very strange QLineEdit inside QMenu glitch under extreemly specific conditions
Summary: Very strange QLineEdit inside QMenu glitch under extreemly specific conditions
Status: RESOLVED WORKSFORME
Alias: None
Product: Breeze
Classification: Plasma
Component: QStyle (show other bugs)
Version: 5.7.3
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Hugo Pereira Da Costa
URL: https://github.com/technic/qt5-bug/bl...
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-31 10:56 UTC by Alex Maystrenko
Modified: 2022-03-26 04:35 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Maystrenko 2016-08-31 10:56:33 UTC
This strange thing initially happened in LXQt project, you may see discussion here https://github.com/lxde/lxqt/issues/1109

However, I've figured out that this looks like Qt, Breeze or Xorg bug. I am posting it here, because in my case it is reproducible only with breeze and oxygen theme, but not with fusion. Maybe, additional factors like video drivers are also important.

I created an example, that illustrates the bug:

There is a QWidgetAction based on QLineEdit, that is added to QMenu. There is a function, that deletes old QMenu instance and creates a new one, but QWidgetAction is moved to new parent with removeAction/addAction functions. Everything works fine so far.

But next two lines of code added simultaneously, break widget drawing. We set background for the root QMenu, and added a child QMenu:
mMenu->setStyleSheet("QMenu { background: rgba(240, 0, 0, 100%); }");
QMenu *submenu = new QMenu(mMenu);

Hmm...?)))



Reproducible: Always

Steps to Reproduce:
1. go to https://github.com/technic/qt5-bug and build the project
2. run it and wait for 3sec (glitch creation is managed by timers)

Actual Results:  
A transparent space instead of QLineEdit (see screenshot)

Expected Results:  
QLineEdit popup:
https://github.com/technic/qt5-bug/blob/master/ok.png

Only breeze and oxygen themes are affected. Fusion theme works fine.

Qt 5.7.0, radeon opensource driver.
Comment 1 Alex Maystrenko 2016-08-31 10:58:47 UTC
Screenshot with a glitch
https://github.com/technic/qt5-bug/blob/master/bug.png
Comment 2 Alex Maystrenko 2016-08-31 11:04:24 UTC
In console I see QXcbConnection: XCB error: 8 (BadMatch)
Comment 3 Kai Uwe Broulik 2016-08-31 11:08:06 UTC
I can confirm the issue by running the aforementioned project. Running with Fusion theme works fine but with Breeze the line edit disappears.
Comment 4 Hugo Pereira Da Costa 2016-09-08 08:57:07 UTC
Hello,
thanks for reporting. I'm investigating. I suspect this has to do with setting Qt::WA_TranslucentBackground to QMenu (line 326 of breezestyle.cpp), in order to have round corners.
Will keep you posted. (in the meanwhile if someone can try disable that setting and try see if the bug is still present, that would help)

Best,

Hugo
Comment 5 Hugo Pereira Da Costa 2016-09-08 11:13:02 UTC
Hello again,
I can reproduce.
so indeed this is some sort of conflict between setting a stylesheet, and setting the WA_TranslucentBackground flag. 
So really, something fishy with Qt.

Now, I do not want to remove the flag as set from the style (that would make all the menus boring square, in breeze and oxygen). However, I found to possible fixes, on the application side (the qt-bug).

Fix 1: call mMenu->ensurePolished() before setting the stylesheet. For some reason, setting the TranslucentBackground flag before setting the stylesheet fixes it (likely because the stylesheet disables again the flag).

Fix 2: rather than using a stylesheed for just changing the background color, use native Qt API and change the QPalette: 
    auto palette = mMenu->palette();
    palette.setColor( QPalette::Background, qRgb( 240, 0, 0 ) );
    mMenu->setPalette( palette );

Here, both changes fix the issue. Any chance you can push that upstream ? 

Best regards, 

Hugo
Comment 6 Hugo Pereira Da Costa 2016-09-08 11:17:51 UTC
Note that among the two fixes, the second is prefered: it keeps the menu corners round.
The first one gets you a square menu (by effectively disabling the style's rounding feature, by calling setStylesheet after polishing)
Comment 7 Alex Maystrenko 2016-09-08 11:50:13 UTC
Thank you for the investigation. I remember that I have encountered similar wired behavior with WA_TranslucentBackground in the lxqt-panel.
I think it is possible to push a workaround to LXQt project. Should we inform Qt developers about this thing?
Comment 8 Janet Blackquill 2022-02-24 00:23:43 UTC
Is this still relevant/reproducible?
Comment 9 Bug Janitor Service 2022-03-11 04:35:34 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 10 Bug Janitor Service 2022-03-26 04:35:21 UTC
This bug has been in NEEDSINFO status with no change for at least
30 days. The bug is now closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

Thank you for helping us make KDE software even better for everyone!