Hi all,
I have a question regarding the general conception of a Qt program.
I have an application that uses several types of items, say cars, drivers, mechanics, etc... (which all have a few specific values: brand of a car, age of a driver, etc...). The application has a list of every of these items, and performs an optimisation based on the informations they contain.
The user interface I'm building uses the model / view framework (mainly QTableModel and QTableView), to allow the edition of items. I built a model for every type of item (specializations of QTableModel), so I have: CarModel, DriverModel, etc...
All these classes actually share a lot of code: addItem, removeItem,... All I could find is to copy/paste the code in the different classes.
Is there not something simpler to do? I was thinking of using templates, and doing something like:
template<class T> class MyModel (which would include a few pure virtual functions)
which I would then specialize for cars, drivers, mechanics,...
But I see in the documentation of moc that signals and slots aren't supported in template classes.
So how could I keep my code simple, and avoid having the same piece of code copied in several classes?
Thanks,
Xavier
Bookmarks