- 
    
Bug
 - 
    Resolution: Fixed
 - 
    
P3: Somewhat important
 - 
    6.2.1, 6.4.0
 - 
    None
 - 
    Windows (Not version-specific)
Tested on Qt 6.2.1, but looking at the source code, it looks like this has always been there, and never changed (I looked at 6.4.0)
 
- 
        
 - 
        ecd41111a3 (qt/qtbase/dev) 30daa8248e (qt/qtbase/6.4) 44efb4a73c (qt/qtbase/6.3)
 
Context
I'm using http://accessibilityinsights.io/ to make sure my QML application passes Microsoft requirements for accessibility.
There's only one error that I couldn't resolve : Qml ComboBoxes don't have the ExpandCollapse pattern.
Code to reproduce:
ComboBox {
 model: ["First", "Second", "Third"]
}
Error
Accessibility Insights says "An element of the given ControlType must support the ExpandCollapse pattern. Section 508 502.3.10" and "How to fix:"
- Make sure the element has the appropriate ControlType property for its function.
 - If the current ControlType is correct, modify the element to support the ExpandCollapse pattern.
 
I did not find any related issues in the Qt bug list.
Digging deeper
I went on to examine Qt's source code and found the following file:
qtbase\src\plugins\platforms\windows\uiautomation\qwindowsuiamainprovider.cpp
Here's the part that was most relevant:
case UIA_ExpandCollapsePatternId: // Menu items with submenus. if (accessible->role() == QAccessible::MenuItem && accessible->childCount() > 0 && accessible->child(0)->role() == QAccessible::PopupMenu) { *pRetVal = new QWindowsUiaExpandCollapseProvider(id()); }
Which means that for the ExpandCollapse pattern to work, there must be a MenuItem object (the qml combobox doesn't have that), nor a child that's a PopupMenu.
After further testing, the ExpandCollapse pattern works fine in a menu (from QWidgets), but not in qml.
I couldn't change the combobox's role (Accessible.MenuItem), as it doesn't register for some reason (perhaps because of the C++ backend)
I tried "hacking" this in qml, to see if it could work, by testing the following code:
MenuItem
{
 text: "test"
 Rectangle {
 Accessible.role: Accessible.PopupMenu
 visible:false // to make the state "collapsed" by default.
 }
}
With this fake popup menu, I have the ExpandCollapse pattern. But obviously this isn't a ComboBox.
Solution
I think the only way to resolve this issue is to change qwindowsuiamainprovider.cpp to add the ExpandCollapse pattern to ComboBoxes, and it should work for both QtWidgets and Qml.
Accessibility concerns
I don't know much about accessibility, but if someone uses the narrator and sees that it's a combobox item type (it is), then they can probably manage.
But, Microsoft is becoming super strict and not allowing any Accessibility issues.
So I think this request will come in really soon from others (I'm working directly with OEMs that need Microsoft requirements before everyone else)
Resources
While looking for bugs, I found out that anrocha could be the person to help with this!
- relates to
 - 
                    
QTBUG-105283 Quick Combo Boxes should support programmatic expansion/collapse
-         
 - Reported
 
 -