qt


How to implement a TreeView whose underlying data is a qvector<qvector<CustomClass>> data and can update the view whenever data is modified?


I have a data structure QVector < QVector< CustomClass>> called raw_data and I want to show it within a QTreeView in my Qt application, like the following graph:
\Index1
|- raw_data[Index1][0] // Assume my CustomClass can be convert ed to string
|- raw_data[Index1][1]
...
|- raw_data[Index1][N1-1]
\Index2
|- raw_data[Index2][0]
|- raw_data[Index2][1]
...
|- raw_data[Index2][N2-1]
...
Here, raw_data can be modified by many other processing functions in my project and what I want to implement is updating the QTreeView automatically whenever some function has modified raw_data. (E.g. delete/insert)
I know model-view-controller is a solution for displaying underlying data in some view, but I don't really understand how to implement this.
Each views use a model to store the data. A Model is an abstraction for data in tables, lists, trees and each cell may store info of different properties like text, colors, states, etc.
To customize the model, you need to extends QAbstractItemModel or any of it derived classes. You may find more info about subclassing the model in here.
To indicate the View that data has changed, your model need to emit dataChanged whenever any value (with visual impact) is modified.

Related Links

How to set Qmake -project default values?
Separating data and test settings in QTests
How can I expand a list in a Toolbar in QML when the user tap the title of the it?
Qt WebEngine error while using example “contentmanipulation”
How to show multiple tooltips at once
Custom winapi Window frame without DWM
QGrahpicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget), widget change to 0x0( nullptr,NULL)
How to get an auto incremented ID of a newly inserted row
Qt 5.8.0 MSVC - Getting a weird compiler error
ubuntu 16 cannot install robomongo
Appropriate technique to create new object by user on front end in Qt
Library libqtx does not show in include
ZoomIn Keyboard Controls
QLineEdit Password - Obscure All But Last Character
qmake doesn't search library path
Beaglebone black freeze at “reading u-boot.img” stage

Categories

HOME
firebase
opencart
braintree
facebook-android-sdk
spring-security-oauth2
yeoman-generator-angular
game-maker
outlook-restapi
smartgwt
dhcp
fresco
phonegap-build
uima
checkout
nose
significance
android-permissions
web-analytics
el
opentext
fusetools
plyr
cellular-network
python-imageio
tsung
dnsmasq
vcenter
om-next
cloudera-manager
creation
nppexec
variable-variables
telephonymanager
ng-repeat
aurelia-http-client
classnotfoundexception
access-denied
vungle-ads
xcode8.2
intellij-lombok-plugin
image-registration
karabiner
winston
swiperefreshlayout
dcount
jpda
oci
fragmentstatepageradapter
right-to-left
deferred-rendering
cfwheels
bjam
cache-manifest
textscan
ipod
clarion
console.log
prism-4
mxe
mojo
fat32
uno
password-recovery
inequality
visual-c++-2012
squeezebox
windows-messages
hyperloglog
accountmanager
spring-social-linkedin
discovery
objective-c-runtime
aero
chefspec
ip-geolocation
jdom
autosize
exponent
acpi
fbml
servercontrol
firefly-mv
qt-mobility
azure-acs
webresponse
git-log
turbine
hungarian-notation
bass
odac
ixmldomdocument
resharper-5.0
yahoo-maps
eai
fuzzy-comparison
ntruencrypt

Resources

Encrypt Message