[Interest] Regarding displaying data from database in a single column only

André Somers andre at familiesomers.nl
Mon Feb 16 10:51:16 CET 2015


Jha Sonakumar schreef op 16-2-2015 om 09:49:
>
> Hi all,
>
> Generally we use to display data from database by *QTableView * rows.
>
> But i need to display all items of a row in a cell of a column,so in 
> this way there will be only one column.
>
> Could you please share any idea.
>
>
>
Easiest would be to create a proxy model. In this proxy model, you fix 
the column count to 1. Then, you reimplement the data() method to return 
the data you need for every role. I usually create my own roles enum 
that extends the standard roles; one role for each logical piece of data.

I actually also in my own models provide such an interface: make all 
data for a logical item available for all columns that contain aspects 
of that item through roles. That makes it easier to integrate with QML, 
but also I find that other code becomes easier. So, all columns provide 
the same data, except for the DisplayRole and other standard roles that 
I need.

To display all that, you can use a custom delegate that uses more than 
just your Qt::DisplayRole.

André
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150216/a2b45ac5/attachment.html>


More information about the Interest mailing list