PDA

View Full Version : QStandardItem as separator to QListView



cyang
17th September 2010, 20:22
Hi all,

I just started coding Qt, and am struggling with some UI features. Please let me know if I can find some sample code or just API for this issue, thanks!

I am using a QStandardItemModel to store QStandardItem to display in QListView, I wonder if there's a simple separator type for QStandardItem, so that I can feed into QStandardItemModel then QListView directly? Essentially I want to implement a address book like list with separators in the list.



QListview *listview = new QListView()
QStandardItemModel *model = new QStandardItemModel();

for (int i =0; i<num; i++)
{
QStandardItem *item = new QStandardItem();
model->appendRow(item);
}

listview->setModel(model);

tbscope
18th September 2010, 06:56
Add an item with the text "------------------------" ?

If that isn't what you mean, you'll need to look into delegates for example.
You can add an item with a custom role for example and the delegate can react on that role to draw a nice line for example.