Hi,<div><br></div><div>Sorry to bump this thread again.</div><div><br></div><div>I am almost done with my PYQT application but I  still have this glitch on my button delegate..</div><div><br></div><div>Are there any alternatives to using buttons delegate in tableviews?</div>

<div><br></div><div>But I need a button per row...</div><div><br></div><div>Best,</div><div>Cris<br><br><div class="gmail_quote">On 8 November 2012 21:53, Cristobal Infante <span dir="ltr"><<a href="mailto:cgcris@gmail.com" target="_blank">cgcris@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Erik,<div><br></div><div>Thanks again for your reply, It's good to know that at least I am making some progress</div>

<div>with PyQt and have arrived to a dead end ;)</div><div><br></div><div>To be honest I am fine with it, will just have to explain my users they will have to</div>
<div>activate the cell before clicking.</div><div><br></div><div>The important thing was to have my button clicking and that has been achieved.</div><div><br></div><div>Thanks!</div><div>Cris</div><div class="HOEnZb"><div class="h5">

<div><br><br><div class="gmail_quote">
On 8 November 2012 17:09, Erik Janssens <span dir="ltr"><<a href="mailto:Erik.Janssens@conceptive.be" target="_blank">Erik.Janssens@conceptive.be</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<u></u>
<div style="font-family:'Sans Serif';font-size:9pt;font-weight:400;font-style:normal">
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">Hi Chris,</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">I'm not sure if this can be fixed, maybe you can ask this</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">on the Qt info mailing list.  If it can be fixed, I'm interested</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">in the solution ;)</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">What happens is, when the TableWidget receives a click, it</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">creates an editor, but the editor has not yet received the</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">click.   That is perfect in most cases, but in case you draw</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">a button it isn't.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">Cheers,</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">Erik</p><div><div>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">On Wednesday, November 07, 2012 02:50:17 PM Cristobal Infante wrote:<br></p>
<p style="margin-top:12px;margin-bottom:12px;margin-left:40px;margin-right:40px;text-indent:0px">Hi Eric,<br><br>Thanks for the tip, I've managed to get my button inside my tableview.<br><br>There is only one thing that bothers me, not sure if it is a limitation or something I can fix.<br>


<br>To be able to press a button, I need to "activate" the containing cell with a click. <br>Once the cell is active I can press the button. This could become confusing for your average user.<br><br>Is this fixable?<br>


<br>Best,<br>Cris<br><br><br><br><br></p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:40px;margin-right:40px;text-indent:0px">On 6 November 2012 22:05, <<a href="mailto:Erik.Janssens@conceptive.be" target="_blank"><span style="text-decoration:underline;color:#0057ae">Erik.Janssens@conceptive.be</span></a>> wrote:<br>


</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:44px;margin-right:40px;text-indent:0px">The delegate itself can only paint, it cannot react to</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:44px;margin-right:40px;text-indent:0px">clicks, you should implement the createEditor method,</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:44px;margin-right:40px;text-indent:0px">the editor then reacts to clicks</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:44px;margin-right:40px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:44px;margin-right:40px;text-indent:0px">On Tuesday, November 06, 2012 09:59:03 PM Cristobal Infante wrote:<br></p>
<p style="margin-top:12px;margin-bottom:12px;margin-left:84px;margin-right:80px;text-indent:0px">Hi,</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px"><br></p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px">I<span style="font-family:'Arial,Liberation Sans,DejaVu Sans,sans-serif';font-size:14px"> am trying to embed a button per row inside a tableview. My botton are drawing correctly as delegates but are not reacting to any clicks.</span> </p>



<p style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px"><span style="font-family:'Arial,Liberation Sans,DejaVu Sans,sans-serif';font-size:14px"><br></span></p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px"><span style="font-family:'Arial,Liberation Sans,DejaVu Sans,sans-serif';font-size:14px">Should I be setting flags for this column? so far I have something like:</span><br>


</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px"><br></p>
<pre style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px;background-color:#eeeeee"><span style="font-family:'Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif';font-size:14px"> if index.column() == 14:</span> </pre>



<pre style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px;background-color:#eeeeee"><span style="font-family:'Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif';font-size:14px">        flags |=  QtCore.Qt.ItemIsSelectable  | QtCore.Qt.ItemIsUserCheckable | Qt.ItemIsEnabled</span> </pre>



<pre style="margin-top:0px;margin-bottom:10px;margin-left:84px;margin-right:80px;text-indent:0px;background-color:#eeeeee"><span style="font-family:'Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif';font-size:14px">    return flags    </span> </pre>



<p style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px"><br></p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px"><br></p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px">This is my delegate, but how do I make the button react to clicks?</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px"><br></p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px">Thanks,</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px">cris</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px"><br></p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px"><br></p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px"><br></p>
<pre style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px;background-color:#eeeeee"><span style="font-family:'Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif';font-size:14px">class AButton(QtGui.QStyledItemDelegate):</span> </pre>



<pre style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px;background-color:#eeeeee"><span style="font-family:'Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif';font-size:14px">mouse_isPressed = False</span> </pre>



<pre style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px;background-color:#eeeeee"><span style="font-family:'Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif';font-size:14px"><br>


</span></pre>
<pre style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px;background-color:#eeeeee"><span style="font-family:'Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif';font-size:14px">def __init__(self, parent = None):</span> </pre>



<pre style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px;background-color:#eeeeee"><span style="font-family:'Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif';font-size:14px">    QtGui.QStyledItemDelegate.__init__(self, parent)</span> </pre>



<pre style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px;background-color:#eeeeee"><span style="font-family:'Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif';font-size:14px"><br>


</span></pre>
<pre style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px;background-color:#eeeeee"><span style="font-family:'Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif';font-size:14px">def boundingRect(self):</span> </pre>



<pre style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px;background-color:#eeeeee"><span style="font-family:'Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif';font-size:14px">    return QtCore.QRectF(0, 0, 40, 40)</span> </pre>



<pre style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px;background-color:#eeeeee"><span style="font-family:'Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif';font-size:14px"><br>


</span></pre>
<pre style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px;background-color:#eeeeee"><span style="font-family:'Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif';font-size:14px">def paint(self, painter, option, widget = 0):</span> </pre>



<pre style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px;background-color:#eeeeee"><span style="font-family:'Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif';font-size:14px">    opt = QtGui.QStyleOptionButton()</span> </pre>



<pre style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px;background-color:#eeeeee"><span style="font-family:'Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif';font-size:14px"><br>


</span></pre>
<pre style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px;background-color:#eeeeee"><span style="font-family:'Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif';font-size:14px">    opt.state = ((QtGui.QStyle.State_Sunken if self.mouse_isPressed else QtGui.QStyle.State_Raised) | QtGui.QStyle.State_Enabled)</span> </pre>



<pre style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px;background-color:#eeeeee"><span style="font-family:'Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif';font-size:14px">    opt.text = self.text()</span> </pre>



<pre style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px;background-color:#eeeeee"><span style="font-family:'Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif';font-size:14px">    opt.icon = self.icon()</span> </pre>



<pre style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px;background-color:#eeeeee"><span style="font-family:'Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif';font-size:14px">    opt.rect = option.rect</span> </pre>



<pre style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px;background-color:#eeeeee"><span style="font-family:'Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif';font-size:14px">    opt.palette = option.palette</span> </pre>



<pre style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px;background-color:#eeeeee"><span style="font-family:'Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif';font-size:14px">    QtGui.QApplication.style().drawControl(QtGui.QStyle.CE_PushButton, opt, painter)</span> </pre>



<pre style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px;background-color:#eeeeee"><span style="font-family:'Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif';font-size:14px"><br>


</span></pre>
<pre style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px;background-color:#eeeeee"><span style="font-family:'Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif';font-size:14px">def text(self):</span> </pre>



<pre style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px;background-color:#eeeeee"><span style="font-family:'Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif';font-size:14px">    return QtCore.QString("hi")</span> </pre>



<pre style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px;background-color:#eeeeee"><span style="font-family:'Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif';font-size:14px"><br>


</span></pre>
<pre style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px;background-color:#eeeeee"><span style="font-family:'Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif';font-size:14px">def icon(self):</span> </pre>



<pre style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px;background-color:#eeeeee"><span style="font-family:'Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif';font-size:14px">    return QtGui.QIcon()</span> </pre>



<pre style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px;background-color:#eeeeee"><span style="font-family:'Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif';font-size:14px"><br>


</span></pre>
<pre style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px;background-color:#eeeeee"><span style="font-family:'Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif';font-size:14px">def mousePressEvent(self, event):</span> </pre>



<pre style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px;background-color:#eeeeee"><span style="font-family:'Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif';font-size:14px">    self.mouse_isPressed = True</span> </pre>



<pre style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px;background-color:#eeeeee"><span style="font-family:'Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif';font-size:14px">    print "HELLO"</span> </pre>



<pre style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px;background-color:#eeeeee"><span style="font-family:'Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif';font-size:14px">    self.update()</span> </pre>



<pre style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px;background-color:#eeeeee"><span style="font-family:'Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif';font-size:14px"><br>


</span></pre>
<pre style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px;background-color:#eeeeee"><span style="font-family:'Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif';font-size:14px">def mouseReleaseEvent(self, event):</span> </pre>



<pre style="margin-top:0px;margin-bottom:0px;margin-left:84px;margin-right:80px;text-indent:0px;background-color:#eeeeee"><span style="font-family:'Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif';font-size:14px">    self.mouse_isPressed = False</span> </pre>



<pre style="margin-top:0px;margin-bottom:10px;margin-left:84px;margin-right:80px;text-indent:0px;background-color:#eeeeee"><span style="font-family:'Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif';font-size:14px">    self.update()</span> </pre>



<p style="margin-top:0px;margin-bottom:0px;margin-left:44px;margin-right:40px;text-indent:0px"><br><br></p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><br>_______________________________________________<br>PyQt mailing list    <a href="mailto:PyQt@riverbankcomputing.com" target="_blank"><span style="text-decoration:underline;color:#0057ae">PyQt@riverbankcomputing.com</span></a><br>


<a href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt" target="_blank"><span style="text-decoration:underline;color:#0057ae">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</span></a><br></p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><br></p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><br><br></p></div></div></div><br>_______________________________________________<br>
PyQt mailing list    <a href="mailto:PyQt@riverbankcomputing.com" target="_blank">PyQt@riverbankcomputing.com</a><br>
<a href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt" target="_blank">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br></blockquote></div><br></div>
</div></div></blockquote></div><br></div>