Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Qt QAbstractItemModel subclass for JSON data

License

NotificationsYou must be signed in to change notification settings

sadeqAlbana/json-model

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A QAbstractItemModel subclass for json data

this model takes a json array to view it in Qt Item views

Features

  • supports Qt widgets views
  • supports Qt Quick controls 1 views
  • supports Qt Quick controls 2 views
  • supports the newDelegateChooser using a special role
  • custom header data
  • ability to view nested data

Usage

  • you just pass the data to the constructor or call thesetupData() method
  • there is an optionalColumnList parameter that use can use to define custom header data, customDelegateChooser role values and point to nested json keys

sample code

QJsonArray modelData;   for(int i=1 ; i<1001; i++){       QJsonObject row{           {"name", QString("item %1").arg(i)},           {"stock", QJsonObject{{"location", QString("wharehouse %1").arg(i)},{"qty", i}}},           {"value", i*100},       };       modelData << row;   }      JsonModel model(modelData,ColumnList() <<                   Column{"name","Name",QString(),"text"} <<                   Column{"qty","Stock","stock","text"} << //nested key                   Column{"value","Value",QString(),"currency"});

License

GNU Lesser General Public License v3.0. See LICENSE file


[8]ページ先頭

©2009-2025 Movatter.jp