<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>In Search of a Good Title &#187; mousePressEvent</title>
	<atom:link href="http://curtis.humphreyonline.us/tag/mouse-press-event/feed" rel="self" type="application/rss+xml" />
	<link>http://curtis.humphreyonline.us</link>
	<description>Curtis M. Humphrey's Website</description>
	<lastBuildDate>Wed, 02 Jun 2010 17:04:44 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Qt mousePressEvent and mouseReleaseEvent fun!</title>
		<link>http://curtis.humphreyonline.us/code/qt-code/qt-mousepressevent-and-mousereleaseevent-fun</link>
		<comments>http://curtis.humphreyonline.us/code/qt-code/qt-mousepressevent-and-mousereleaseevent-fun#comments</comments>
		<pubDate>Mon, 02 Mar 2009 18:03:34 +0000</pubDate>
		<dc:creator>Curtis M. Humphrey</dc:creator>
				<category><![CDATA[Qt Code]]></category>
		<category><![CDATA[mousePressEvent]]></category>
		<category><![CDATA[mouseReleaseEvent]]></category>
		<category><![CDATA[QGraphicsItem]]></category>
		<category><![CDATA[Qt FYI]]></category>

		<guid isPermaLink="false">http://curtis.humphreyonline.us/?p=61</guid>
		<description><![CDATA[This would have been good to know beforehand regarding mouse events&#8230;
Apparently in Qt, QGraphicsItem&#8217;s mouse events are a little different from the model I had in my head from Actionscript. In actionscript when a user uses the mouse to move over and then click on an MovieClip object these events occur (ignoring mouse movement events):

onRollOver
onPress
onRelease
onRollOut

In [...]


Related posts:<ol><li><a href='http://curtis.humphreyonline.us/articles/word-2007-spell-checking-inside-tables' rel='bookmark' title='Permanent Link: word 2007 spell checking inside tables'>word 2007 spell checking inside tables</a></li>
<li><a href='http://curtis.humphreyonline.us/code/qt-code/grabbing-all-qgraphicitems-current-viewable-in-a-qgraphicview' rel='bookmark' title='Permanent Link: Grabbing all QGraphicItems current viewable in a QGraphicView'>Grabbing all QGraphicItems current viewable in a QGraphicView</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>This would have been good to know beforehand regarding mouse events&#8230;</p>
<p>Apparently in <a title="Qt" href="http://doc.trolltech.com/">Qt</a>, <a title="QGraphicsItem" href="http://doc.trolltech.com/4.4/qgraphicsitem.html">QGraphicsItem</a>&#8217;s mouse events are a little different from the model I had in my head from <a title="Actionscript" href="http://en.wikipedia.org/wiki/Actionscript">Actionscript</a>. In actionscript when a user uses the mouse to move over and then click on an MovieClip object these events occur (ignoring mouse movement events):</p>
<ol>
<li>onRollOver</li>
<li>onPress</li>
<li>onRelease</li>
<li>onRollOut</li>
</ol>
<p>In Qt it is not quite the same. If the QGraphicsItem accepts mouse clicks but is not <a title="GraphicsItemFlag" href="http://doc.trolltech.com/4.4/qgraphicsitem.html#GraphicsItemFlag-enum" target="_blank">movable or selectable</a> then these are its events (again ignoring mouse movement events):</p>
<ol>
<li>hoverEnterEvent</li>
<li>mousePressEvent</li>
<li>hoverLeaveEvent</li>
</ol>
<p>Notice in Qt there is not a mouse release event called. Qt does have a <a href="http://doc.trolltech.com/4.4/qgraphicsitem.html#mouseReleaseEvent">mouseReleaseEvent</a><strong> </strong>but it is only called if the item is movable or selectable (both not set by default).</p>
<p>This fact would have been good to know. I had been allowing QGraphicsItems to move during debuging and had been using mouseReleaseEvent as my click event. When I removed the debuging code suddenly I could not click my items, which was most distressing as it was only minutes away from my live demo. Luckly, I discovered this Qt fact, changed the event to  <a href="http://doc.trolltech.com/4.4/qgraphicsitem.html#mousePressEvent">mousePressEvent</a> and got it all working.</p>
<p>How demos work as told on <a href="http://www.phdcomics.com/comics/archive.php?comicid=821">PHD comics</a>.</p>


<p>Related posts:<ol><li><a href='http://curtis.humphreyonline.us/articles/word-2007-spell-checking-inside-tables' rel='bookmark' title='Permanent Link: word 2007 spell checking inside tables'>word 2007 spell checking inside tables</a></li>
<li><a href='http://curtis.humphreyonline.us/code/qt-code/grabbing-all-qgraphicitems-current-viewable-in-a-qgraphicview' rel='bookmark' title='Permanent Link: Grabbing all QGraphicItems current viewable in a QGraphicView'>Grabbing all QGraphicItems current viewable in a QGraphicView</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://curtis.humphreyonline.us/code/qt-code/qt-mousepressevent-and-mousereleaseevent-fun/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
