PDA

View Full Version : how to implement list of lists and display it



FantaZy
21st April 2013, 13:23
Hello, firstly I have to tell that im absolutely beginner in Qt .
My task is to create program which supports a shop. At the beginning i'd like to create a list of products and display it on the screen but i have no idea how to do it. There are a lots of libs and documentation is very extensive that i dont know what and HOW to use it.
My problem on pics looks like this:
8974

and as a result i'd like to get view like this:
8975

amleto
21st April 2013, 14:11
what you want is a tree widget (with multiple columns)

qtreewidget
http://www.youtube.com/watch?v=TpkiVlOS3o4

FantaZy
25th April 2013, 15:45
one more question, how can i save/load my whole complicated structure to file ? i've found s11n for c++ but maybe Qt involves some library ?

Santosh Reddy
25th April 2013, 17:05
One simple way is to use QSettings, it supports most of the Qt types already.

One other you can serialize data into XML stream and save it.

FantaZy
27th April 2013, 14:37
One simple way is to use QSettings, it supports most of the Qt types already.

One other you can serialize data into XML stream and save it.
im not sure that QSettings lives up my expectations because as i've read in documentation it is generally used for saving/reading application settings.
in my case, i'd like to read/write whole data from lists etc.

amleto
27th April 2013, 16:30
have you tried it?

FantaZy
27th April 2013, 16:41
have you tried it?
no, i've looked into documenation - http://qt-project.org/doc/qt-4.8/qsettings.html
Useful method which I see here are beginReadArray and beginWriteArray . okei but i see i should use it.

amleto
28th April 2013, 00:46
and what is wrong with
qsettings.html#setValue
?

(you can put quite a lot inside a QVariant)