[Qt-interest] Mouse double click.

Alexandre Beraud aberaud at infflux.com
Thu Feb 19 09:43:16 CET 2009


Hi,

In your QTreeView derivative, reimplement virtual void 
*mouseDoubleClickEvent 
<http://doc.trolltech.com/4.3/qwidget.html#mouseDoubleClickEvent>* ( 
QMouseEvent * /event/ ).
Then use indexAt(const QPoint & /point/) and you should get the 
corresponding QModelIndex.
Another (more complicated) way would be to use a QItemDelegate to handle 
everything in each cell as well
as an eventFilter() function. I think that with the first solution you 
should be able to do whatever you want.

Regards,

Alex


Shabd Swarup V a écrit :
> QMouseEvent event(QEvent::MouseButtonDblClick,
> treeView->pos(),Qt::LeftButton,0, 0);
> QCoreApplication::sendEvent(treeView, &event);
>
> This is what I am trying to do, but the problem is that I have to send
> the event on an index inside the treeView while treeView->pos() returns
> the position of the treeView widget as a whole. I am unable to find the
> screen coordinates of the index.
>
> Am I missing something very obvious? Please suggest.
>
> Thanks,
> Shabd
>
>
> -----Original Message-----
> From: qt-interest-bounces at trolltech.com
> [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Malyushytsky,
> Alex
> Sent: Thursday, February 19, 2009 11:05 AM
> To: qt-interest at trolltech.com
> Subject: Re: [Qt-interest] Mouse double click.
>
> Make sure this item is visible and compute its screen coordinate, then
> construct QMouseEvent?
> Not sure why don't call appropriate slot right away instead.
>
> Regards,
>    Alex Malyushytsky
>
>
>
> ________________________________________
> From: qt-interest-bounces at trolltech.com
> [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Shabd Swarup V
> Sent: Wednesday, February 18, 2009 8:41 PM
> To: qt-interest at trolltech.com
> Subject: [Qt-interest] Mouse double click.
>
> Hi,
>
> I need to fire a mouse double click on a particular index(QModelIndex)
> in a QTreeView and a QListWidget.
> I can fire the event on the widget as a whole, but how do I do it on a
> particular index?
>
> Please let me know.
>
> Regards,
> Shabd
>
>
>
> ------------------------------------------------------------------------
> ---------------------------
> Weidlinger Associates, Inc. made the following annotations.
>
> "This message and any attachments are solely for the intended recipient
> and may contain confidential or privileged information. If you are not
> the intended recipient, any disclosure, copying, use, or distribution of
> the information included in this message and any attachments is
> prohibited. If you have received this communication in error, please
> notify us by reply e-mail and immediately and permanently delete this
> message and any attachments. Thank you."
>
> "Please consider our environment before printing this email."
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
>   


-- 
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