[Qt-interest] display one database column as two in QTableView
Israel Brewster
israel at frontierflying.com
Wed Mar 17 21:47:38 CET 2010
That worked perfectly, thanks!!! I would have responded sooner, but I didn't get a chance to try this out until just now. Thanks again!
On Mar 13, 2010, at 1:15 AM, André Somers wrote:
> Glad to hear the approach is working out for you. To fix your issue, you
> just need to reimplement the flags() method too, and return the correct
> flags. What you are seeing is that the default implementation returns 0 (it
> does not know about your new column), and that means that it will be
> disabled. Just reimplement flags(), and return the correct combination of
> flags.
>
> André
>
> -----Oorspronkelijk bericht-----
> Van: qt-interest-bounces at trolltech.com
> [mailto:qt-interest-bounces at trolltech.com] Namens Israel Brewster
> Verzonden: vrijdag 12 maart 2010 21:29
> Aan: Qt-interest Interest
> Onderwerp: Re: [Qt-interest] display one database column as two in
> QTableView
>
>
> On Mar 12, 2010, at 8:12 AM, Israel Brewster wrote:
>
>>
>> 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 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...
>>>>
>>> [snip].
>>
>> ...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
>> :-)
>
> Ok, I'm making progress. By overriding the columnCount() function of the
> QSqlTableModel, I got all the columns I wanted, populated with the data I
> want. Overriding the setData() function also worked to re-combine the
> separate date/time columns back to the timestamp.
>
> However, the last column in my model, while it does display the proper data,
> is drawn grayed out, as though disabled. Clicking on the column does
> nothing- I can't select or edit anything in this column. It's as though
> there is still something, somewhere, thinking that there should be one fewer
> columns than I am showing, and thus disabling the last column (since the
> column number is too high). Anyone know how I can fix this? Thanks.
>
> -----------------------------------------------
> Israel Brewster
> Computer Support Technician II
> Era Alaska
> 5245 Airport Industrial Rd
> Fairbanks, AK 99709
> (907) 450-7250 x293
> -----------------------------------------------
>
>
>
> _______________________________________________
> 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/20100317/c741ea46/attachment.bin
-------------- next part --------------
More information about the Qt-interest-old
mailing list