本文整理汇总了C++中QListWidget::addAction方法的典型用法代码示例。如果您正苦于以下问题:C++ QListWidget::addAction方法的具体用法?C++ QListWidget::addAction怎么用?C++ QListWidget::addAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QListWidget
的用法示例。
在下文中一共展示了QListWidget::addAction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: reloadAssistantXml
void MainWindow::reloadAssistantXml(const QString &path)
{
if (m_assistantXmlPath != path) {
m_assistantXmlPath = path;
foreach (QListWidget* widget, m_assistantWidgets) {
widget->deleteLater();
}
m_assistantWidgets.clear();
if (m_assistantXmlPath.isEmpty()) {
qDebug() << "No assistant defined.";
} else {
AssistantXmlReader reader;
reader.readFile(m_assistantXmlPath);
QAction* action_insert = new QAction(this);
action_insert->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Enter));
for (int i = 0; i < reader.size(); ++i) {
const Assistant* assistant = reader.assistant(i);
QListWidget* view = newAssistantListWidget(ASSISTANT_ICON_SIZE, this);
for (int j = 0; j < assistant->size(); ++j) {
const AssistantItem* assistantItem = assistant->item(j);
QListWidgetItem* listWidgetItem =
new QListWidgetItem(iconFromSvg(ASSISTANT_ICON_SIZE, assistantItem->icon()),
assistantItem->name(), view);
listWidgetItem->setData(ASSISTANT_ITEM_DATA_ROLE, assistantItem->data());
listWidgetItem->setData(ASSISTANT_ITEM_NOTES_ROLE, assistantItem->notes());
}
m_assistantToolBox->addItem(view, assistant->name());
connect(view, SIGNAL(itemDoubleClicked(QListWidgetItem*)),
this, SLOT(onAssistanItemDoubleClicked(QListWidgetItem*)));
connect(view, SIGNAL(itemSelectionChanged()),
this, SLOT(onAssistantItemSelectionChanged()));
QAction* action = new QAction(this);
action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Return));
m_assistantInsertSignalMapper->setMapping(action, view);
connect(action, SIGNAL(triggered()),
m_assistantInsertSignalMapper, SLOT(map()));
view->addAction(action);
m_assistantWidgets << view;
}
}
}