[Qt-interest] Mouse double click.
Andreas Pakulat
apaku at gmx.de
Thu Feb 19 12:40:16 CET 2009
On 19.02.09 16:59:44, Shabd Swarup V wrote:
> Hi Guys,
>
> I'm sure you're aware of my problem by now :)
>
> This is what I've tried to do after your suggestions:
>
> {
> QWidget* targetWidget = targetObject->viewport();
>
> //Get QRect for the given index.
> const QRect indexRect = targetObject->visualRect(index);
>
> //Get position relative to parent widget.
> const QPoint parentPosition =
> targetObject->mapToParent(QPoint(indexRect.x(),indexRect.y()));
>
> //Get global position.
> const QPoint globalPosition =
> targetWidget->mapToGlobal(QPoint(indexRect.x(),indexRect.y()));
>
> //Create mouseevent for double click.
> QMouseEvent event(QEvent::MouseButtonDblClick, parentPosition,
> globalPosition, Qt::LeftButton,0, 0);
>
> //Send event to the widget.
> QCoreApplication::sendEvent(targetWidget, &event);
> }
>
> It's not working :( What am I doing wrong?
I suggest to use postEvent, not sendEvent. Also you probably shouldn't send
a double-click like this, but rather press+release+press+release. Qt will
then translate that into a double-click.
Andreas
--
You are fighting for survival in your own sweet and gentle way.
More information about the Qt-interest-old
mailing list