[Qt-interest] Mouse double click.

Alexandre Beraud aberaud at infflux.com
Thu Feb 19 11:43:14 CET 2009


Hi,

Ok, my bad ! Then the code you sent in an earlier e-mail, using 
sendEvent(), seems good, but you have to construct the virtual mouse 
position yourself. If you have the QModelIndex then you can use the 
visualRect() function of the treeview to get an appropriate coordinate. 
Otherwise you must at least know the row and column of the item.

Regards,

Alex


Shabd Swarup V a écrit :
> 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





More information about the Qt-interest-old mailing list