[PyQt] Model/View programming

Philippe Crave philippe.crave at gmail.com
Thu May 6 20:24:19 BST 2010


Yes, I use that in the model also.
but now, I need to iterate over the row, in the tableView. I want to
hide row when the data is an empty string.
I found that I can get the string with self.currentIndex().data().toString()
so, I suppose that I have to find a way to modify the currentIndex


2010/5/6 Scott Frankel <frankel at circlesfx.com>:
>
> On May 6, 2010, at 9:46 AM, Philippe Crave wrote:
>
>> actually, I just want to loop over the rows.
>> I do not find a max_row, or an iterator over the rows of a Table.
>
> Take a look at your model's rowCount() and record() methods.  I think you'll
> want to be iterating over the records in your model, not the tableview
> itself.
>
> Scott
>
>
>> 2010/5/6 Philippe Crave <philippe.crave at gmail.com>:
>>>
>>> thank you, both of you !
>>> I will check the filtering solution.
>>> I am now implementing the setColumnHidden. just have to customize a
>>> QTableView class. seems simple.
>>>
>>> by the way, do you know how to get the total number of row in a table ?
>>> i must be blind, but I could not find it.
>>>
>>> 2010/5/6 Christian Brugger <brugger.chr at googlemail.com>:
>>>>
>>>> Just to outline my idea a bit more:
>>>> Yeah one model class and one view class. But with different filters
>>>> between
>>>> model and views. You wouldn't just attach your 2 views to your model,
>>>> but
>>>> rather would attach each view to an individual filter (could be two
>>>> objects
>>>> of the same custom filter class) and then would attach both filters to
>>>> your
>>>> model. Such a custom filter could be created as described in the docs:
>>>>
>>>> http://doc.trolltech.com/4.6/model-view-proxy-models.html#custom-filtering-models
>>>> But as far as I see, Benjamin has found a much simpler solution, if you
>>>> only
>>>> want so hide columns. I would test his suggestion first and check if it
>>>> fits
>>>> your needs.
>>>> Christian
>>>>
>>>> On Thu, May 6, 2010 at 5:15 PM, Philippe Crave
>>>> <philippe.crave at gmail.com>
>>>> wrote:
>>>>>
>>>>> looks like that I have to do a QAbstractTableModel for each QTableView,
>>>>> no
>>>>> ?
>>>>> sounds strange, I thought that the idea was to have only one model
>>>>> that will serve data to several views.
>>>>>
>>>>> 2010/5/6 Philippe Crave <philippe.crave at gmail.com>:
>>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> I am reading the chapter 14 of Mark Summerfield.
>>>>>> I work with custom model and custom delegate.
>>>>>>
>>>>>> in the sample from the book, we have 1 tableView linked to one model.
>>>>>> It's simple to get 2 tableView linked to the same model.
>>>>>>
>>>>>> my Model has got 4 columns.
>>>>>> I would like that TableView_1 show the 2 first column only, and
>>>>>> TableView_2 show the 2 others.
>>>>>>
>>>>>> what is the good way to do it ?
>>>>>> actually, the content of the model will be given to the view in the
>>>>>> data(self, index, role=Qt.DisplayRole) method from the custom model.
>>>>>> is there a way to know which view needs data in that data method ?
>>>>>>
>>>>>> thanks,
>>>>>>
>>>>>> Philippe
>>>>>>
>>>>> _______________________________________________
>>>>> PyQt mailing list    PyQt at riverbankcomputing.com
>>>>> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>>>>
>>>>
>>>
>> _______________________________________________
>> PyQt mailing list    PyQt at riverbankcomputing.com
>> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
>


More information about the PyQt mailing list