Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
how to represent contents of Qvector
jamesmfarrow last edited by jamesmfarrow
Hello everyone, I have a struct of Qstrings(name age address) stored in a QVector and would like to show each name in a box/container/widget alphabetically top to bottom. Then be able click on a name and the additional info is then shown. Which is the best way to do this?
Sounds rather like a job for a small SQLite database.
In any case, you can:
Thanks! I will read up on the example shown. Trying to do a really simple contacts app. Thought I could use the vector of structs for the data...
Then start directly with the database. It's clearly a better container and long term storage for that kind of data.
Thanks! I am trying to learn Qt and C++ - this project is an exercise so I can get a feel for Qt and using widgets layouts buttons etc. I won't be using it anger... That is the reason I am using a vector - it will only store maybe a 10 -12 items at most to check the other functionality I am trying to write.
Then building a model on top of it will also be an interesting exercice.
What you can do is to create your version with vector plus model on top and once you have that working, move to a database and you'll see that the change needed should be minimal.
JonB last edited by
If you implement the
QAbstractTableModelapproach, you will also find that you can present a data grid of the rows & columns in your data for free, by just putting a QTableView on to view it :)
Thanks everyone. I will read up on the examples that you have listed and see what I can come up with. No doubt I will be back when I get stuck :)