[Qt-interest] display one database column as two in QTableView
Israel Brewster
israel at frontierflying.com
Fri Mar 12 18:12:02 CET 2010
On Mar 9, 2010, at 5:56 AM, Andre Somers wrote:
> Israel Brewster wrote:
>> On Mar 8, 2010, at 11:28 AM, André Somers wrote:
>>
>>
>>> Alternatively, you could create a proxy model that splits the date column
>>> into two separate columns. This would also work on databases that don't
>>> support editable queries.
>>>
>>
>> I was thinking about something like that, but hadn't quite figured it out yet. If I'm thinking right, I would then need to override the data() and setData() functions to translate between the real model and proxy, and the columnCount function to return one additional column. Am I missing anything there? I'll give it a try here in a bit to see what happens. Thanks.
>>
> I think that should work, but I am not sure on how to implement the
> mapping functions that are also in the QAbstractProxyModel class in this
> case. Not sure you need them either in your application.
Mapping functions aren't an issue for me here. However, turns out overriding the row count function only gets me halfway there. It does add another column to the display, and by overriding the data function I can get the first few columns populated the way I want, but the data() function is never called for that last column - it's as though data() is only called for the number of columns in the underlying model. So I guess my next attempt will be to override the columnCount() function of the underlying model as well and see what that does. Hopefully it doesn't just crash the program :-)
>
> André
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
-----------------------------------------------
Israel Brewster
Computer Support Technician II
Era Alaska
5245 Airport Industrial Rd
Fairbanks, AK 99709
(907) 450-7250 x293
-----------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Israel Brewster.vcf
Type: text/directory
Size: 417 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100312/e924da25/attachment.bin
-------------- next part --------------
More information about the Qt-interest-old
mailing list