[Qt-interest] Using QAbstractTableModel with Custom Class

Mandeep Sandhu mandeepsandhu.chd at gmail.com
Wed Jun 30 13:00:08 CEST 2010


>> So assuming for example my QMap contained wto entries what I'd want to see
>> in the QTableView are two rows by x rows (with headers). Column 0 would
>> display the name of the file currently being processed, the next column
>> would display the number of lines to process in this file, the third column
>> would display the number of rows processed so far.
>
> This is doable.
>
> You can subclass QAbstractTableModel for this purpose.

Refer to this link:
http://ptgmedia.pearsoncmg.com/images/0131872494/samplechapter/blanchette_ch10.pdf

It shows how to write your own custom models (got it from QT
docs)...and it even shows an implementation of subclassing a
QAbstractTableModel ! :)

HTH,
-mandeep


>
> Override the data(const QModelIndex &index, int role) function to
> return your custom values.
>
> You can use your QMap to access the instance of the worker thread  and
> return the appropriate value for the respective row/col num, as
> specified in the model index passed here.
>
> HTH,
> -mandeep
>
>
>>
>> Is this even possible, or is it the Worker that needs to be a derivative of
>> QAbstractTable | Item Model I have googled of course but I've not found
>> anythign that comes close.
>>
>> --
>> Bill
>>
>>
>>
>>
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at trolltech.com
>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>
>>
>




More information about the Qt-interest-old mailing list