[Interest] Qt 5: how to disable single-click activation in QAbstractItemView's?

Bache-Wiig Jens Jens.Bache-Wiig at digia.com
Thu Dec 27 22:14:35 CET 2012


It is probably good that it is the same setting across styles as I would argue you would expect single click to be for instance a KDE desktop setting and not something an arbitrary style should be overriding. But if the behaviour is unexpected on your system, you can file a bug against it.

That said, it should be relatively easy to work around this in an application by creating a custom proxy style:

 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_ItemView_ActivateItemOnSingleClick)
             return 0;
         return QProxyStyle::styleHint(hint, option, widget, returnData);
     }
 };

Just set this as your application style and it should revert to the old behaviour regardless what your existing application style is.

Regards,
Jens

On Dec 27, 2012, at 9:28 PM, R. Reucher <rene.reucher at batcom-it.net> wrote:

> Hi!
> 
> I successfully managed to "port" all of my major applications to Qt 5, but I'm 
> facing some issues... the one that bothers me the most at the moment is the 
> fact that now every style seems to activate items on a *single* mouse-click, 
> in Qt 4 this only happens with certains styles (i. e. imported ones like 
> Oxygen from KDE 4).
> 
> Is there some easy way to revive the "old" (Qt 4) behavior? I actually find it 
> very annoying...
> 
> Thanks in advance, René
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest




More information about the Interest mailing list