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

Michael Lawrence lawrence.michael at gene.com
Mon Apr 19 02:07:15 CEST 2010


Just committed the DataFrameModel class. Use qdataFrameModel() to construct
it. qdataFrame() to get the data.frame back out. See comments in the
dataframe.R file.

I'll be shifting focus away from Qt for a couple weeks and towards the
plumbr package, which will provide mutable, dynamic tabular data models,
mostly in support of qtpaint and interactive graphics in general.

On Thu, Apr 15, 2010 at 6:42 PM, Michael Lawrence <michafla at gene.com> wrote:

>
>
> On Thu, Apr 15, 2010 at 4:28 PM, John Verzani <verzani at math.csi.cuny.edu>wrote:
>
>> Dear Michael,
>>
>> I haven't wrapped my head around roles yet, so maybe this is nonsense, but
>> a few things came to mind:
>>
>> * the character vector storing roles might be expanded to a list for
>> objects that are have two classes. I'm thinking of the case of dates, which
>> some times take on a class of  "POSIXt"  "POSIXct"
>>
>
> The character vectors have nothing to do with classes. I will code this up
> over the weekend and you'll understand what I mean.
>
>
>> * Will there be a conversion back to a data frame as well? (The model just
>> uses text if I'm not mistaken)
>>
>>
> The data.frame will be stored with the model, so it can be easily
> extracted. A bigger problem is that the DataFrameModel class is not defined
> at the Smoke level. Right now it is returned as a pointer cast to its
> parent, QAbstractTableModel. That means we can't distinguish it to know that
> we can just yank out the DF.
>
>>
>> --John
>>
>>
>> On Thu, Apr 15, 2010 at 1:45 PM, Michael Lawrence <
>> lawrence.michael at gene.com> wrote:
>>
>>> 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
>>>>
>>>
>>>
>>
>>
>> --
>> 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/20100418/ce614367/attachment.htm 


More information about the Qtinterfaces-devel mailing list