Frage

I'm currently working with the QCalendarWidget and I need some ideas to accomplish the following.

What would be the best way to add the selecteDate from a QCalendarWidget and a number to some sort of table. What I want is basically to have a list of dates with a number attached to each date, these numbers will be added together and the result will be displayed in a QLabel, I also want to be able to delete rows and again update the QLabel every time a row is deleted.

I also want to be able to save the list to an external file.

Should I use a QStringListModel or a QTableView?

How would you accomplish this?

I'm not expecting any code just a general procedure.

Please see the attached image for more details.

QCalendarWidget

War es hilfreich?

Lösung

Should I use a QStringListModel or a QTableView?

You may want to familiarize yourself with the model/view framework. To put it simply, a model is the actual data that you have and it is independent of how it should be displayed. A view is a particular display implementation of a model. So you could use a model like the QStandarItemModel to store your String+number data and display the model in a QTableView.

Model/View Tutorial from Qt website here QStandardItemModel class here. Has a simple example inside there.

And, for writing and reading the data to a file, I suggest you could use the QXmlStreamWriter/Reader classes. Refer to Qt xmlWriter/xmlReader

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top