[Qt-interest] custom designer plugin / populate list widget

Jan janusius at gmx.net
Thu Jul 16 23:32:25 CEST 2009


Hi,

I created a designer plugin (list widget) with a custom contextmenu 
extension. By triggering the menu action the list is populated with 
items (columns from a database). Here is some code.

within a query.next() loop:

QListWidgetItem *item = new QListWidgetItem(q.value(1).toString());
item->setData(Qt::DisplayRole, q.value(1));
item->setData(Qt::DisplayPropertyRole, q.value(1));
item->setData(Qt::CheckStateRole, Qt::Checked);
item->setFlags(item->flags() | Qt::ItemIsEditable);
myCoustomListWidget->addItem(item);

The problem:

If I try to edit the list afterwards designer's listwidget editor does 
not read the contents from the list properly. All Item text values 
(DisplayRole) are empty. If I save the file and reload everything is 
perfect. Does anyone know what I am missing? I guess I have to notify 
some part of designer that the list widget contents changed...

Jan



More information about the Qt-interest-old mailing list