[RQt-devel] Question about Qt$QComboBox in qtbase

Michael Lawrence lawrence.michael at gene.com
Thu Apr 15 19:45:48 CEST 2010


I started working on this today. A simple table model is easy to implement.
The design of the Qt item model framework is different from GtkTreeView, in
that there is a 1-1 correspondence between model and view columns, except
each model column yields different data depending on the specified "role".
GTK+ mapped attributes of view columns (similar to roles) to separate model
columns. The 1-1 mapping in Qt is nice, but at the R level, we just have a
data.frame, so considering roles will take some thought.

Right now I think that we will take a data.frame, along with a character
vector for each role indicating the mapping. And a colnames argument that
specifies which columns actually become columns in the model. With sensible
defaults this should be simple for the use case of just displaying the
data.frame as text.

On Wed, Apr 14, 2010 at 1:43 PM, John Verzani <verzani at math.csi.cuny.edu>wrote:

> Thanks Michael. WIll check it out. Yes, I definitely miss rGtkDataFrame for
> qtbase. My gWidgetsQt versions that use the table widget are really slow
> even for moderately sized data sets. --John
>
>
> On Wed, Apr 14, 2010 at 1:11 PM, Michael Lawrence <
> lawrence.michael at gene.com> wrote:
>
>> Alright, I think it's fixed in svn. Was deleting the QStandardItem, even
>> though Qt owned it (in the model). Unfortunately, Qt has fairly ad-hoc
>> memory ownership policies compared to GTK+.
>>
>> Also, in this simple case, you might find cb$insertItem(i-1, letters[i])
>> to be easier than explicitly creating the QStandardItem.
>>
>> At some point we will need vectorized functions for populating data models
>> like rGtkDataFrame.
>>
>> Michael
>>
>>
>> On Wed, Apr 14, 2010 at 9:48 AM, Michael Lawrence <michafla at gene.com>wrote:
>>
>>>
>>>
>>> On Wed, Apr 14, 2010 at 7:41 AM, John Verzani <verzani at math.csi.cuny.edu
>>> > wrote:
>>>
>>>> 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.)
>>>>
>>>>
>>>> library(qtbase)
>>>>
>>>> testit <- function(i) {
>>>>   cb <- Qt$QComboBox()
>>>>   mod <- cb$model()
>>>>
>>>>   ## set values
>>>>   sapply(seq_along(letters), function(i) {
>>>>     item <- Qt$QStandardItem(letters[i])
>>>>     mod$setItem(i-1, item)
>>>>   })
>>>>
>>>>   cb$setCurrentIndex(2)
>>>>   cat(i, cb$model()$item(2)$text(), "\n")
>>>> }
>>>>
>>>>
>>>> ##
>>>> for(i in 1:1000) {
>>>>   out <- try(testit(i), silent=TRUE)
>>>>   if(inherits(out, "try-error")) {
>>>>     print(i)
>>>>     stop(i)
>>>>   }
>>>> }
>>>>
>>>> ## eventually dies but not consistently, e.g:
>>>> ...
>>>> 8 c
>>>> [1] 9
>>>> Error in eval.with.vis(expr, envir, enclos) :
>>>>   Error in cat(i, cb$model()$item(2)$text(), "\n") :
>>>>   attempt to apply non-function
>>>>
>>>> (Basically what happens is all items in the model are set to NULL, so
>>>> the call to the text method fails.)
>>>>
>>>>
>>> Yea it looks like corruption somewhere. No idea where though, will have
>>> to look into it.
>>>
>>> Thanks,
>>> Michael
>>>
>>>
>>>>
>>>> > sessionInfo()
>>>> R version 2.10.1 (2009-12-14)
>>>> i486-pc-linux-gnu
>>>>
>>>> locale:
>>>> [1] en_US.UTF-8
>>>>
>>>> attached base packages:
>>>> [1] stats     graphics  grDevices utils     datasets  methods   base
>>>>
>>>>
>>>> other attached packages:
>>>> [1] qtbase_0.6-2
>>>>
>>>> --
>>>> John Verzani
>>>> Chair, Department of Mathematics
>>>> College of Staten Island, CUNY
>>>> verzani at math.csi.cuny.edu
>>>>
>>>> _______________________________________________
>>>> Qtinterfaces-devel mailing list
>>>> Qtinterfaces-devel at lists.r-forge.r-project.org
>>>>
>>>> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/qtinterfaces-devel
>>>>
>>>>
>>>
>>
>
>
> --
> John Verzani
> Chair, Department of Mathematics
> College of Staten Island, CUNY
> verzani at math.csi.cuny.edu
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.r-forge.r-project.org/pipermail/qtinterfaces-devel/attachments/20100415/490be2b5/attachment.htm 


More information about the Qtinterfaces-devel mailing list