View Full Version : model/view json data displaying

26th June 2012, 22:58

I'm using QT for years but non UI classes only so I'm UI newbie and also have newbie question.

I have json data which would like to show to user (some of them are static texts (QLabel) some of them are editable (QTextEdit).

I'm passing through MVC documentation in QT but not sure which approach should use to display my data.

I was trying to use QDataWidgetMapper but this display just one row from my data. Is there possibility to display all rows?

Is better to use ListView instead? Thanks in advance.


26th June 2012, 23:30
listwidget, treewidget etc are easier to use than mvc listview etc. However listview does sound like it is what you desire.

26th June 2012, 23:42
Isn't listview limited to icon and label in one row?
I need e.g.:
QTextEdit QButton

in "one" row (probably in some layout). Seems I need to create custom view for that?

27th June 2012, 01:00
QTableView/QTreeView is primarily for display of tabular/tree data where an editor is created on a cell as-required (i.e. the editing widgets are not persistent). You can place persistent widgets into the view with some limitations. If you want a grid of permanent widgets then you may opt for just that, a grid layout filled with discrete widgets. It really depends on your actual requirements.

27th June 2012, 08:53
I know I can use grid layout but there is one problem.
If I have 100 json items for displaying then I can create grid layout with widgets
but I need notifications which item was edited and I was thinking about nicer way like
connect 100x signal for button clicked or so. Maybe my direction is wrong that is the reason why
I would like to clarify before coding something ;). Thanks.

27th June 2012, 09:13
Like I said:

It really depends on your actual requirements.
Now we know you are talking about 100 rows of stuff then the layout approach becomes less suitable. A QTableView/QTableWidget with a delegate to display the data and create appropriate editors as required seems a better fit.