class Plugin {
public:
//snipped constructor code ...
};
~Plugin() {};
};
int main(int argc, char *argv[])
{
QList<Plugin *> pluginList;
pluginList <<
new Plugin
("plugin1",
"plugin1 description",
"mr ed",
QPixmap("icon.png"));
pluginList <<
new Plugin
("plugin2",
"plugin2 description",
"mrs ed",
QPixmap("icon2.png"));
foreach(Plugin *plugin, pluginList) {
item->setData(Qt::DisplayRole, plugin->pluginName);
item->setData(Qt::DecorationRole, plugin->pluginIcon);
item->setData(Qt::UserRole + 1, plugin->pluginDescription);
item->setData(Qt::UserRole + 2, plugin->pluginAuthor);
listWidget->addItem(item);
}
PluginDelegate *pluginDelegate = new PluginDelegate;
listWidget->setItemDelegate(pluginDelegate);
listWidget->show();
return app.exec();
}
class Plugin {
public:
Plugin(QString name, QString desc, QString author, const QPixmap &icon) {
//snipped constructor code ...
};
~Plugin() {};
QString pluginName;
QString pluginDescription;
QString pluginAuthor;
QPixmap pluginIcon;
};
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QListWidget *listWidget = new QListWidget;
QList<Plugin *> pluginList;
pluginList << new Plugin("plugin1", "plugin1 description", "mr ed", QPixmap("icon.png"));
pluginList << new Plugin("plugin2", "plugin2 description", "mrs ed", QPixmap("icon2.png"));
foreach(Plugin *plugin, pluginList) {
QListWidgetItem *item = new QListWidgetItem;
item->setData(Qt::DisplayRole, plugin->pluginName);
item->setData(Qt::DecorationRole, plugin->pluginIcon);
item->setData(Qt::UserRole + 1, plugin->pluginDescription);
item->setData(Qt::UserRole + 2, plugin->pluginAuthor);
listWidget->addItem(item);
}
PluginDelegate *pluginDelegate = new PluginDelegate;
listWidget->setItemDelegate(pluginDelegate);
listWidget->show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks