Results 1 to 6 of 6

Thread: model/view json data displaying

  1. #1
    Join Date
    May 2009
    Posts
    55
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default model/view json data displaying

    Hi,

    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.

    Marek

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: model/view json data displaying

    listwidget, treewidget etc are easier to use than mvc listview etc. However listview does sound like it is what you desire.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  3. #3
    Join Date
    May 2009
    Posts
    55
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: model/view json data displaying

    Isn't listview limited to icon and label in one row?
    I need e.g.:
    QLabel
    QTextEdit QButton
    QSpinBox

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

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: model/view json data displaying

    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.

  5. #5
    Join Date
    May 2009
    Posts
    55
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: model/view json data displaying

    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.

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: model/view json data displaying

    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.

Similar Threads

  1. How copy data from one model view to another
    By breakthecode in forum Newbie
    Replies: 14
    Last Post: 8th December 2011, 06:39
  2. Replies: 1
    Last Post: 24th February 2011, 05:54
  3. Model / View and data structures
    By laszlo.gosztola in forum Newbie
    Replies: 0
    Last Post: 2nd December 2010, 05:13
  4. Table view->model->set data
    By tulsi in forum Qt Programming
    Replies: 3
    Last Post: 21st April 2009, 08:36
  5. Table Model / View Problem -- Data Not Displaying
    By jhendersen in forum Qt Programming
    Replies: 1
    Last Post: 22nd April 2007, 06:45

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.