PDA

View Full Version : How to make a dynamically created user menu with checkbox



Cyrebo
29th March 2013, 00:23
Hi, I want to make a program where the user can create his/her own menu using my program. The application pulls the options(e.g apples, oranges etc..) from a sqlite db and then places it all tidely on a grid layout/widget of some sort. I currently have the data on the db but I just need to pull and display something like apples 1 2 3 where the 1,2,3 is how much you like them and so on for bananas, oranges and whatever else is on the database.

Whats the best widget to use to pull and display this on a UI? Can someone show me an example where you create checkboxes for each lets say newly dynamically created label on your grid layout/widget of some sort?

Thanks in advance!

anda_skoa
2nd April 2013, 09:07
I think I would approach this by first creating a widget for the rating input, e.g. a simple widget with a horizontal layout and radio buttons for each level.

If you only want to display/input ratings, then the most simple layout for the whole form is QFormLayout. You simply add rows for each fruit and a rating widget as the widget.
If you have more data for each item, then you are probably better of with a grid layout.

Alternatively you could go with a QTableView and implement the rating input through a delegate for the respective column.
Given that you seem to have only started using Qt recently I would go for the widget based approach first though :)

Cheers,
_