本文整理汇总了C++中QMenu::setDisabled方法的典型用法代码示例。如果您正苦于以下问题:C++ QMenu::setDisabled方法的具体用法?C++ QMenu::setDisabled怎么用?C++ QMenu::setDisabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMenu
的用法示例。
在下文中一共展示了QMenu::setDisabled方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addCopyCompatibleMenu
QMenu* WidgetBase::addCopyCompatibleMenu (
QMenu* menu, const char* nameOp,
const boost::shared_ptr<QAction>* actionCopyOp,
IsCopyCompatibleType isCopyCompatible) const
{
size_t viewCount = GetSettings ().GetViewCount ();
bool actions = false;
QMenu* menuOp = menu->addMenu (nameOp);
if (viewCount > 1)
{
ViewNumber::Enum currentViewNumber = GetViewNumber ();
for (size_t i = 0; i < viewCount; ++i)
{
ViewNumber::Enum otherViewNumber = ViewNumber::Enum (i);
if (CALL_MEMBER (*this, isCopyCompatible) (
currentViewNumber, otherViewNumber))
{
menuOp->addAction (actionCopyOp[i].get ());
actions = true;
}
}
}
if (! actions)
menuOp->setDisabled (true);
return menuOp;
}
示例2: addCopyMenu
void WidgetBase::addCopyMenu (
QMenu* menu, const char* nameOp,
const boost::shared_ptr<QAction>* actionCopyOp) const
{
QMenu* menuOp = menu->addMenu (nameOp);
if (GetViewCount () > 1)
{
for (size_t i = 0; i < GetViewCount (); ++i)
{
ViewNumber::Enum viewNumber = ViewNumber::Enum (i);
if (viewNumber == GetViewNumber ())
continue;
menuOp->addAction (actionCopyOp[i].get ());
}
}
if (GetViewCount () == 1)
menuOp->setDisabled (true);
}
示例3: s
MainMenu::MainMenu(bool autoclose, const QStringList &runList, const QStringList &busyList, QWidget *parent) :
QMenu(parent),
SingletonWidget(this)
{
move(QCursor::pos());
QAction *act = addAction(style()->standardIcon(QStyle::SP_DriveCDIcon), tr("Install Application"));
act->setData(Install);
act->setEnabled(busyList.isEmpty());
addSeparator();
QFileInfoList pList = FS::data().entryInfoList(QDir::AllDirs | QDir::NoDotAndDotDot);
if (pList.isEmpty())
addEmpty(this);
else
{
sortList(pList);
for (const QFileInfo &pInfo : pList)
{
QString hash = pInfo.fileName();
QFileInfoList sList = FS::shortcuts(hash).entryInfoList(QDir::Files);
sortList(sList, false);
QSettings s(FS::prefix(hash).absoluteFilePath(".settings"), QSettings::IniFormat);
s.setIniCodec("UTF-8");
QString name = s.value("Name").toString();
QMenu *pMenu = addMenu(getPrefixIcon(hash), QString(name).replace('&', "&&"));
bool run = runList.contains(hash);
bool busyOrRun = busyList.contains(hash) || run;
if (sList.isEmpty())
addEmpty(pMenu);
else
{
QDir iDir = FS::icons(hash);
for (const QFileInfo &shortcut : sList)
{
QString base = shortcut.fileName();
QIcon icon = iDir.exists(base) ? QIcon(iDir.absoluteFilePath(base)) :
style()->standardIcon(QStyle::SP_FileLinkIcon);
QSettings s(shortcut.absoluteFilePath(), QSettings::IniFormat);
s.setIniCodec("UTF-8");
QString name = s.value("Name").toString();
act = pMenu->addAction(icon, QString(name).replace('&', "&&"));
act->setProperty("PrefixHash", hash);
act->setProperty("Exe", FS::toUnixPath(hash, s.value("Exe").toString()));
act->setProperty("WorkDir", FS::toUnixPath(hash, s.value("WorkDir").toString()));
act->setProperty("Args", s.value("Args").toString());
if (s.value("Debug", true).toBool())
{
act->setData(Debug);
act->setProperty("Shortcut", shortcut.absoluteFilePath());
}
else
act->setData(Run);
}
}
pMenu->addSeparator();
QMenu *ccMenu = pMenu->addMenu(style()->standardIcon(QStyle::SP_ComputerIcon), tr("Control Center"));
act = ccMenu->addAction(style()->standardIcon(QStyle::SP_MediaPlay), tr("Run File"));
act->setProperty("PrefixHash", hash);
act->setData(RunFile);
act = ccMenu->addAction(style()->standardIcon(QStyle::SP_DirOpenIcon), tr("Browse"));
act->setProperty("PrefixHash", hash);
ccMenu->addSeparator();
QMenu *uMenu = ccMenu->addMenu(style()->standardIcon(QStyle::SP_DialogResetButton), tr("Utilities"));
uMenu->setDisabled(busyOrRun);
act = uMenu->addAction(QIcon(":/winecfg"), tr("Winecfg"));
act->setProperty("PrefixHash", hash);
act->setProperty("Exe", FS::toUnixPath(hash, "C:\\windows\\system32\\winecfg.exe"));
act->setData(Run);
act = uMenu->addAction(QIcon(":/regedit"), tr("Regedit"));
act->setProperty("PrefixHash", hash);
act->setProperty("Exe", FS::toUnixPath(hash, "C:\\windows\\regedit.exe"));
act->setData(Run);
act = ccMenu->addAction(style()->standardIcon(QStyle::SP_FileDialogDetailedView), tr("Edit"));
act->setProperty("PrefixHash", hash);
act->setData(Edit);
act->setDisabled(busyOrRun);
ccMenu->addSeparator();
act = ccMenu->addAction(style()->standardIcon(QStyle::SP_TrashIcon), tr("Delete"));
act->setProperty("PrefixName", name);
act->setProperty("PrefixHash", hash);
act->setData(Delete);
act->setDisabled(busyOrRun);
pMenu->addSeparator();
act = pMenu->addAction(style()->standardIcon(QStyle::SP_DialogCancelButton), tr("Terminate"));
act->setProperty("PrefixName", name);
act->setProperty("PrefixHash", hash);
act->setData(Terminate);
act->setEnabled(run);
}
}
addSeparator();
act = addAction(style()->standardIcon(QStyle::SP_FileDialogDetailedView), tr("Settings"));
act->setData(Settings);
act->setEnabled(busyList.isEmpty() && runList.isEmpty());
addSeparator();
act = addAction(QIcon::fromTheme("winewizard"), tr("About"));
act->setData(About);
act = addAction(style()->standardIcon(QStyle::SP_DialogHelpButton), tr("Help"));
act->setData(Help);
if (!autoclose)
{
//.........这里部分代码省略.........
示例4: mousePressEvent
void TupPaintArea::mousePressEvent(QMouseEvent *event)
{
#ifdef K_DEBUG
T_FUNCINFO;
#endif
// SQA: Temporal solution for cases when there's no current frame defined
if (!graphicsScene()->currentFrame()) {
return;
}
if (graphicsScene()->currentFrame()->isLocked()) {
#ifdef K_DEBUG
tFatal() << "TupPaintArea::mousePressEvent() - Frame is locked!";
#endif
return;
}
if (k->currentTool.compare(tr("Line Selection")) == 0) {
// If a node is the target... abort!
if (event->buttons() == Qt::RightButton) {
if (qgraphicsitem_cast<TControlNode *>(scene()->itemAt(mapToScene(event->pos()))))
return;
}
}
if (k->currentTool.compare(tr("Object Selection")) == 0) {
if (event->buttons() == Qt::RightButton) {
// If a node is the target... abort!
if (qgraphicsitem_cast<Node *>(scene()->itemAt(mapToScene(event->pos()))))
return;
if (QGraphicsItem *item = scene()->itemAt(mapToScene(event->pos()))) {
if (item->opacity() == 1) {
item->setFlag(QGraphicsItem::ItemIsSelectable, true);
item->setSelected(true);
} else {
return;
}
}
QMenu *menu = new QMenu(tr("Drawing area"));
menu->addAction(kApp->findGlobalAction("undo"));
menu->addAction(kApp->findGlobalAction("redo"));
menu->addSeparator();
QAction *cut = menu->addAction(tr("Cut"), this, SLOT(cutItems()), QKeySequence(tr("Ctrl+X")));
QAction *copy = menu->addAction(tr("Copy"), this, SLOT(copyItems()), QKeySequence(tr("Ctrl+C")));
QAction *paste = menu->addAction(tr("Paste"), this, SLOT(pasteItems()), QKeySequence(tr("Ctrl+V")));
QAction *del = menu->addAction(tr("Delete"), this, SLOT(deleteItems()), QKeySequence(Qt::Key_Delete));
menu->addSeparator();
QMenu *order = new QMenu(tr("Order"));
connect(order, SIGNAL(triggered(QAction*)), this, SLOT(requestMoveSelectedItems(QAction*)));
order->addAction(tr("Send to back"))->setData(MoveBack);
order->addAction(tr("Bring to front"))->setData(MoveFront);
order->addAction(tr("Send backwards"))->setData(MoveBackwards);
order->addAction(tr("Brind forwards"))->setData(MoveForwards);
menu->addMenu(order);
order->setDisabled(true);
menu->addSeparator();
// Code commented temporary while SQA is done
QAction *addItem = menu->addAction(tr("Add to library..."), this, SLOT(addSelectedItemsToLibrary()));
menu->addSeparator();
if (scene()->selectedItems().isEmpty()) {
del->setEnabled(false);
cut->setEnabled(false);
copy->setEnabled(false);
addItem->setEnabled(false);
} else {
QList<QGraphicsItem *> selected = scene()->selectedItems();
foreach (QGraphicsItem *item, selected) {
QDomDocument dom;
dom.appendChild(dynamic_cast<TupAbstractSerializable *>(item)->toXml(dom));
QDomElement root = dom.documentElement();
if (root.tagName() == "symbol") {
QString key = root.attribute("id").toUpper();
if (key.endsWith("JPG") || key.endsWith("PNG") || key.endsWith("GIF") || key.endsWith("XPM")) {
addItem->setEnabled(false);
break;
}
} else if (root.tagName() == "svg") {
addItem->setEnabled(false);
break;
}
}
}
if (k->copiesXml.isEmpty())
paste->setEnabled(false);
if (QMenu *toolMenu = graphicsScene()->currentTool()->menu()) {
menu->addSeparator();
//.........这里部分代码省略.........