Q:

Double Click on QTreeView Expand Item Arrow

In my Qt 5.6.2 project, I noticed that if you double click on a QTreeView item (the actual arrow part, not the item text) the first click toggles the expanded state, and the second click does nothing.
I would instead like the second click to again toggle the expanded state.
I tried treeView->setExpandsOnDoubleClick(false); but the behaviour is still the same since it appears to not affect the arrow part of the item at all. It looks like Qt is deciding for me how the arrow should react to a double click regardless of the property expandsOnDoubleClick. How can I resolve this?
(Note: this behaviour didn't exist in Qt 5.0.2. Unsure about intermediate Qt versions.)

A:

I was able to solve this by subclassing QProxyStyle and checking for the style hint SH_ListViewExpand_SelectMouseType and returning a value of 3 instead of the default 2.
class MyProxyStyle : public QProxyStyle
{
public:
    int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const
    {
        if(hint == QStyle::SH_ListViewExpand_SelectMouseType)
            return 3;
        return QProxyStyle::styleHint(hint, option, widget, returnData);
    }
}

