<div dir="ltr">Thanks for replying...I've updated my code but I still cant get it to work:<div><br></div><div><pre class="" style="margin-top:0px;margin-bottom:1em;padding:5px;border:0px;font-size:13px;width:auto;max-height:600px;overflow:auto;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;color:rgb(57,51,24);word-wrap:normal;background-color:rgb(239,240,241)"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:inherit"><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(16,16,148)">class</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> graphics_Object</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">QtGui</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">QGraphicsPixmapItem</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">):</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(16,16,148)">def</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> __init__</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">self</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">,</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> parent</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">=</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(16,16,148)">None</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">):</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
super</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">switch_Object</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">,</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> self</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">).</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">__init__</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">parent</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">)</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
pixmap </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">=</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">QtGui</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">QPixmap</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(125,39,39)">"item.png"</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">)</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
self</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.graphics</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">_pixItem </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">=</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">QtGui</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">QGraphicsPixmapItem</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">pixmap</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">scaled</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(125,39,39)">40</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">,</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(125,39,39)">40</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">,</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">QtCore</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">Qt</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">KeepAspectRatio</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">))</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
self</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">graphics_pixItem</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">setFlag</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">QtGui</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">QGraphicsPixmapItem</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">ItemIsSelectable</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">)</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
self</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">graphics_pixItem</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">setFlag</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">QtGui</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">QGraphicsPixmapItem</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">ItemIsMovable</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">)</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
self</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">graphics_pixItem</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">setAcceptHoverEvents</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(16,16,148)">True</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">)</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(16,16,148)">def</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> hoverEnterEvent</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">self</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">,</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> event</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">):</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(16,16,148)">print</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(125,39,39)">'hello'</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(16,16,148)">class</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> graphicsScene</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">QtGui</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">QGraphicsScene</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">):</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(16,16,148)">def</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> __init__</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">self</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">,</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> parent</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">=</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(16,16,148)">None</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">):</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
super</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">graphicsScene</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">,</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> self</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">).</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">__init__</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">parent</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">)</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(16,16,148)">def</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> mousePressEvent</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">self</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">,</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> event</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">):</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
self</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">graphics_item </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">=</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> graphics_Object</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">()</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(16,16,148)">def</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> mouseReleaseEvent</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">self</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">,</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> event</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">)</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
self</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">addItem</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">self</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">self</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">graphics_item</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">graphics_pixItem</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">)</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
self</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">graphics_item</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">self</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">graphics_pixItem</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">setPos</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">event</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">scenePos</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">())</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(16,16,148)">class</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">Form</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">QtGui</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">QMainWindow</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">):</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(16,16,148)">def</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> __init__</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">self</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">):</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
super</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">Form</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">,</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> self</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">).</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">__init__</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">()</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
self</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">ui </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">=</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> uic</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">loadUi</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(125,39,39)">'form.ui'</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">)</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
self</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">scene </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">=</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> graphicsScene</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">()</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
self</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">ui</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">view</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">setScene</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">self</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">scene</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">)</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
self</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">setMouseTracking</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(16,16,148)">True</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">)</span></code></pre></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, May 7, 2016 at 10:55 PM, Elvis Stansvik [via Python] <span dir="ltr"><<a href="/user/SendEmail.jtp?type=node&node=5190289&i=0" target="_top" rel="nofollow" link="external">[hidden email]</a>></span> wrote:<br><blockquote style='border-left:2px solid #CCCCCC;padding:0 1em' class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Nesibe,
<br><div><div class="h5"><br>2016-05-07 19:46 GMT+02:00 sw33tz <<a href="http:///user/SendEmail.jtp?type=node&node=5190286&i=0" rel="nofollow" link="external" target="_blank">[hidden email]</a>>:
<br>> I want some small text to pop up when I have my curser over a QGraphicsItem
<br>> in my QGraphicsScene. I have a class that inherits from QGraphicsItem, and
<br>> this represents my graphical items in the scene.
<br>>
<br>> I tried using the QGraphicsItem.hoverEnterEvent and I also set the
<br>> setAcceptHoverEvents(True), but I still can't enable that hover event. I
<br>> also came across an event filter method but I'm not sure where to implement
<br>> it.
<br><br>This seems to work here:
<br><br><br>test.py:
<br><br>from sys import argv, exit
<br><br>from PyQt5.QtCore import Qt
<br>from PyQt5.QtWidgets import QApplication
<br>from PyQt5.QtWidgets import QGraphicsEllipseItem
<br>from PyQt5.QtWidgets import QGraphicsScene
<br>from PyQt5.QtWidgets import QGraphicsView
<br>from PyQt5.QtWidgets import QMainWindow
<br><br><br>class MyItem(QGraphicsEllipseItem):
<br><br> def __init__(self, parent=None):
<br> super(MyItem, self).__init__(parent)
<br><br> self.setRect(50, 50, 50, 50)
<br> self.setBrush(Qt.red)
<br> self.setAcceptHoverEvents(True)
<br><br> def hoverEnterEvent(self, event):
<br> print('hover enter')
<br><br> def hoverLeaveEvent(self, event):
<br> print('hover leave')
<br><br><br>app = None
<br><br><br>def main():
<br> global app
<br><br> app = QApplication(argv)
<br><br> scene = QGraphicsScene()
<br> scene.addItem(MyItem())
<br><br> view = QGraphicsView()
<br> view.setScene(scene)
<br><br> window = QMainWindow()
<br> window.setCentralWidget(view)
<br> window.show()
<br><br> exit(app.exec_())
<br><br><br>if __name__ == '__main__':
<br> main()
<br><br><br>Hope that helps.
<br><br>Best regards,
<br>Elvis
<br></div></div><div><div><div class="h5"><div class='shrinkable-quote'><br>>
<br>> Should I install the event filter in the QGraphicsItem class, or the scene?
<br>> I tried both and I'm still not getting the desired result. I want to be able
<br>> to hover over all the items in the scene.
<br>>
<br>>
<br>> class HoverEventFilter(QtCore.QObject):
<br>> def eventFilter(self, receiver, event):
<br>> if (event.type() == QtCore.QEvent.HoverEnter):
<br>> # this is for test purposes
<br>> print 'hover event'
<br>> return True
<br>> else:
<br>> # Call Base Class Method to Continue Normal Event Processing
<br>> return super(HoverEventFilter, self).eventFilter(receiver,
<br>> event)
<br>>
<br>>
<br>>
<br>> --
<br>> View this message in context: <a href="http://python.6.x6.nabble.com/Hover-Event-for-a-QGraphicsItem-tp5190283.html" rel="nofollow" link="external" target="_blank">http://python.6.x6.nabble.com/Hover-Event-for-a-QGraphicsItem-tp5190283.html</a><br>> Sent from the PyQt mailing list archive at Nabble.com.
<br>> _______________________________________________
</div></div></div>> PyQt mailing list <a href="http:///user/SendEmail.jtp?type=node&node=5190286&i=1" rel="nofollow" link="external" target="_blank">[hidden email]</a>
<br>> <a href="https://www.riverbankcomputing.com/mailman/listinfo/pyqt" rel="nofollow" link="external" target="_blank">https://www.riverbankcomputing.com/mailman/listinfo/pyqt</a></div>_______________________________________________
<br>PyQt mailing list <a href="http:///user/SendEmail.jtp?type=node&node=5190286&i=2" rel="nofollow" link="external" target="_blank">[hidden email]</a>
<br><a href="https://www.riverbankcomputing.com/mailman/listinfo/pyqt" rel="nofollow" link="external" target="_blank">https://www.riverbankcomputing.com/mailman/listinfo/pyqt</a>
<br>
<br>
<hr noshade size="1" color="#cccccc">
<div style="color:#444;font:12px tahoma,geneva,helvetica,arial,sans-serif">
<div style="font-weight:bold">If you reply to this email, your message will be added to the discussion below:</div>
<a href="http://python.6.x6.nabble.com/Hover-Event-for-a-QGraphicsItem-tp5190283p5190286.html" target="_blank" rel="nofollow" link="external">http://python.6.x6.nabble.com/Hover-Event-for-a-QGraphicsItem-tp5190283p5190286.html</a>
</div>
<div style="color:#666;font:11px tahoma,geneva,helvetica,arial,sans-serif;margin-top:.4em;line-height:1.5em">
To unsubscribe from Hover Event for a QGraphicsItem, <a href="" target="_blank" rel="nofollow" link="external">click here</a>.<br>
<a href="http://python.6.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml" rel="nofollow" style="font:9px serif" target="_blank" link="external">NAML</a>
</div></blockquote></div><br></div>
<br/><hr align="left" width="300" />
View this message in context: <a href="http://python.6.x6.nabble.com/Hover-Event-for-a-QGraphicsItem-tp5190283p5190289.html">Re: Hover Event for a QGraphicsItem</a><br/>
Sent from the <a href="http://python.6.x6.nabble.com/PyQt-f1792048.html">PyQt mailing list archive</a> at Nabble.com.<br/>