本文整理汇总了C++中QMenu::setMouseTracking方法的典型用法代码示例。如果您正苦于以下问题:C++ QMenu::setMouseTracking方法的具体用法?C++ QMenu::setMouseTracking怎么用?C++ QMenu::setMouseTracking使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMenu
的用法示例。
在下文中一共展示了QMenu::setMouseTracking方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: contextMenuEvent
void FloatEdit::contextMenuEvent( QContextMenuEvent * event )
{
QMenu * mnuContext = new QMenu( this );
mnuContext->setMouseTracking( true );
QMenu * mnuStd = createStandardContextMenu();
if( validator->canMin() )
mnuContext->addAction( actMin );
if( validator->canMax() )
mnuContext->addAction( actMax );
if( validator->canMin() || validator->canMax() )
mnuContext->addSeparator();
mnuContext->addActions( mnuStd->actions() );
mnuContext->exec( event->globalPos() );
delete mnuStd;
delete mnuContext;
}
示例2: iname
//.........这里部分代码省略.........
// C. This is obviously ridiculous, but the fact that we have programName
// here at all makes me think it exists as some kind of necessary hack
// to coax tr() into behaving nicely. I decided to change it as little
// as possible to get it to compile, and not refactor this down to the
// simplest way to call tr() on a C string.
QString programName(strtoqstr((*it)->getProgramName()));
programName = QObject::tr(programName.toStdString().c_str());
Device *device = (*it)->getDevice();
DeviceId devId = device->getId();
bool connectedIcon = false;
// Determine the proper program name and whether it is connected
if ((*it)->getType() == Instrument::SoftSynth) {
programName = "";
AudioPluginInstance *plugin =
(*it)->getPlugin(Instrument::SYNTH_PLUGIN_POSITION);
if (plugin) {
// we don't translate any plugin program names or other texts
programName = strtoqstr(plugin->getDisplayName());
connectedIcon = (plugin->getIdentifier() != "");
}
} else if ((*it)->getType() == Instrument::Audio) {
connectedIcon = true;
} else {
QString conn = RosegardenSequencer::getInstance()->
getConnection(devId);
connectedIcon = (conn != "");
}
// These two are for selecting the correct icon to display.
bool instrUsedByMe = false;
bool instrUsedByAnyone = false;
if (thisTrackInstr && thisTrackInstr->getId() == (*it)->getId()) {
instrUsedByMe = true;
instrUsedByAnyone = true;
}
// If we have switched to a new device, we'll create a new submenu
if (devId != (DeviceId)(currentDevId)) {
currentDevId = int(devId);
// For selecting the correct icon to display.
bool deviceUsedByAnyone = false;
if (instrUsedByMe)
deviceUsedByAnyone = true;
else {
for (Composition::trackcontainer::iterator tit =
comp.getTracks().begin();
tit != comp.getTracks().end(); ++tit) {
if (tit->second->getInstrument() == (*it)->getId()) {
instrUsedByAnyone = true;
deviceUsedByAnyone = true;
break;
}
Instrument *instr =
studio.getInstrumentById(tit->second->getInstrument());
if (instr && (instr->getDevice()->getId() == devId)) {
deviceUsedByAnyone = true;
}
}
}
QIcon icon
(connectedIcon ?
(deviceUsedByAnyone ?
connectedUsedPixmap : connectedPixmap) :
(deviceUsedByAnyone ?
unconnectedUsedPixmap : unconnectedPixmap));
// Create a submenu for this device
QMenu *subMenu = new QMenu(instrumentPopup);
subMenu->setMouseTracking(true);
subMenu->setIcon(icon);
// Not needed so long as AA_DontShowIconsInMenus is false.
//subMenu->menuAction()->setIconVisibleInMenu(true);
// Menu title
QString deviceName = QObject::tr(device->getName().c_str());
subMenu->setTitle(deviceName);
// QObject name
subMenu->setObjectName(deviceName);
// Add the submenu to the popup menu
instrumentPopup->addMenu(subMenu);
// Connect the submenu to slotInstrumentSelected()
connect(subMenu, SIGNAL(triggered(QAction*)),
this, SLOT(slotInstrumentSelected(QAction*)));
currentSubMenu = subMenu;
} else if (!instrUsedByMe) {