Qt: How to layout records in a grid? QListView or QGridLayout?
Still learning the fundamental concepts...
I want to layout items that come from a database in a grid. Each item will have a custom view with a preview picture, attributes and controls. The grid can change size, i.e. 3, 4, 5 columns (large-small previews).
Is this best done by adding (looping through the table) custom widgets to a grid, or by using icon list view wit开发者_如何学编程h a "delegate"?
Thanks!
My first inclination would be to go with the icon list view and a delegate (especially if you already have your data in model form). If that doesn't work, you might be able to use the icon list view as a guideline to creating your own list view. Two benefits of the views is that they handle a lot of the repositioning of items if something is inserted into the middle, and often have lazy evaluation of data they need. A side benefit of having your data in a model is the ability to use it in other places as well (such as a combo box, if you want to let the user choose one image elsewhere).
精彩评论