[Qt-interest] Mouse double click.

Shabd Swarup V shabd at cadence.com
Thu Feb 19 11:31:55 CET 2009


Hi Alex,

Thanks for being patient, but this also not what I'm looking for. In fact, I need just the opposite of this. 
I am actually trying to simulate user behavior through code. So, I need to simulate a double click on an index in a TreeView.

The purpose is related to testing of an application. I had a look at QTestLib, it seemed to be interesting but I was unable to find this functionality through that.

The inputs I have are:
1. QTreeView object.
2. Index on which double click has to be executed.

The operation I need to do is "double click". I do not worry about the action that will be performed once the double click is executed. That is upto the QTreeView object's implementation.

Hope I am able to describe the problem better this time.

Regards,
Shabd



-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Alexandre Beraud
Sent: Thursday, February 19, 2009 3:50 PM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] Mouse double click.

Hi again,

In this case, install an event filter for your treeview that redirects 
the events to a function of MyTreeViewImpl. Take a look at this link 
(provided that you use Qt 4):
http://doc.trolltech.com/4.3/qobject.html#installEventFilter
You can get the position of the double click from the QEvent and then 
get the QModelIndex from the indexAt() function of the treeview.
I hope that this is what you're looking for.

Regards,

Alex


Shabd Swarup V a écrit :
> Thanks for the response. I think the problem is slightly different.
>
> I am not deriving from the QTreeView class but actually I am writing a class that will do some operations on a particular QTreeView object.
>
> For example, this is one of the methods in my class:
>
> void MyTreeViewImpl::clickRow(QTreeView* targetObject, int row)
> {
>         QAbstractItemModel* model = targetObject->model();
>         QModelIndex index = QModelIndex();
>         
>         index = model->index(row,0);
>
>         targetObject->setCurrentIndex(index);
> }
>
> I need to write another method for double clicking on a particular row/index.
>
> Please suggest.
>
> Thanks,
> Shabd
>
>   


-- 
BERAUD Alexandre
Ingénieur Développement

Infflux - Informatique & Flux
Tel: 01 49 57 92 00 - Fax : 01 49 57 92 01
Mail: aberaud at infflux.com
Visitez notre site :  www.infflux.com


_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list