I am having trouble consistently getting a combobox to behave properly. In particular, with this test case I rarely get past 40 before the process dies. Am I setting up the combobox completely wrong? (I've tried using setItemText but that failed as well and I don't think my issue is having so many widgets open.)<br>
<br><br clear="all">library(qtbase)<br><br>testit <- function(i) {<br> cb <- Qt$QComboBox()<br> mod <- cb$model()<br> <br> ## set values<br> sapply(seq_along(letters), function(i) {<br> item <- Qt$QStandardItem(letters[i])<br>
mod$setItem(i-1, item)<br> })<br> <br> cb$setCurrentIndex(2)<br> cat(i, cb$model()$item(2)$text(), "\n")<br>}<br><br><br>## <br>for(i in 1:1000) {<br> out <- try(testit(i), silent=TRUE)<br> if(inherits(out, "try-error")) {<br>
print(i)<br> stop(i)<br> }<br>}<br><br>## eventually dies but not consistently, e.g:<br>...<br>8 c <br>[1] 9<br>Error in eval.with.vis(expr, envir, enclos) : <br> Error in cat(i, cb$model()$item(2)$text(), "\n") : <br>
attempt to apply non-function<br><br>(Basically what happens is all items in the model are set to NULL, so the call to the text method fails.)<br><br><br>> sessionInfo()<br>R version 2.10.1 (2009-12-14) <br>i486-pc-linux-gnu <br>
<br>locale:<br>[1] en_US.UTF-8<br><br>attached base packages:<br>[1] stats graphics grDevices utils datasets methods base <br><br>other attached packages:<br>[1] qtbase_0.6-2<br><br>-- <br>John Verzani<br>
Chair, Department of Mathematics<br>College of Staten Island, CUNY<br><a href="mailto:verzani@math.csi.cuny.edu">verzani@math.csi.cuny.edu</a><br>