<br><br><div class="gmail_quote">On Fri, Apr 16, 2010 at 4:48 PM, John Verzani <span dir="ltr"><<a href="mailto:verzani@math.csi.cuny.edu">verzani@math.csi.cuny.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
I'm trying to create a virtual function to handle an event. After spending time with the proto package I was hoping that something like this would work:<br><br>library(qtbase)<br>e <- Qt$QLineEdit()<br>e$mousePressEvent <- function(e) print("called")<br>
<br></blockquote><div><br>While it would be possible to extend every Qt class with instance-level "signal" handlers, this would add a significant amount of complexity. For qtpaint, I made an RLayer class that essentially allowed this
for the Layer class. <br><br>The current design of qtpaint though is simply to follow the design of Qt/C++ where methods are defined at the class level. There are signals for most common things, like "clicked" for
QPushButton. How often does one need a mouse click event for QLineEdit? Qt uses signals far less than GTK+, which makes sense, since extending a C++ class is far easier than extending a GObject class in C.<br><br>Honestly, I kind of like forcing people to follow an OOP approach when creating complex GUIs. Unfortunately, this might restrict some aspects of gWidgets...<br>
<br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">However, it doesn't. I know how to work around this by extending the QLineEdit class, defining a method mousePressEvent in that class which can consider the state of the instance in the call. Along the lines of<br>
<br>qsetClass("gwQLineEdit", Qt$QLineEdit, function() super(parent))<br>qsetMethod("mousePressEvent", gwQLineEdit, function(e) print("do something depending on value of this...."))<br><br>This just seems like I am doing it wrong. (For one thing it calls this method even if no event handler for the instance is defined.) Is there a better way?<br clear="all">
<br>Thanks for any help,<br><br>John<br><font color="#888888">-- <br>John Verzani<br>Chair, Department of Mathematics<br>College of Staten Island, CUNY<br><a href="mailto:verzani@math.csi.cuny.edu" target="_blank">verzani@math.csi.cuny.edu</a><br>
</font><br>_______________________________________________<br>
Qtinterfaces-devel mailing list<br>
<a href="mailto:Qtinterfaces-devel@lists.r-forge.r-project.org">Qtinterfaces-devel@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/qtinterfaces-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/qtinterfaces-devel</a><br>
<br></blockquote></div><br>