本文整理汇总了C++中QMenu::parentWidget方法的典型用法代码示例。如果您正苦于以下问题:C++ QMenu::parentWidget方法的具体用法?C++ QMenu::parentWidget怎么用?C++ QMenu::parentWidget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMenu
的用法示例。
在下文中一共展示了QMenu::parentWidget方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: closeAllMenus
void Menu::closeAllMenus()
{
QMenu* parentMenu = this;
while (parentMenu) {
parentMenu->close();
parentMenu = qobject_cast<QMenu*>(parentMenu->parentWidget());
}
}
示例2: saveToShelf
bool KxMenuItem::saveToShelf(int whichAction)
{
// First check that this is not a submenu item or separator
if(menu() != NULL || isSeparator()) return false;
// Only menu items from main menu bar are allowed to be saved to shelf.
// Get topmost parent menu
QMenu *menu = qobject_cast<QMenu *>(parent());
QMenu *parentMenu = qobject_cast<QMenu *>(menu->parentWidget());
while(parentMenu) {
menu = parentMenu;
parentMenu = qobject_cast<QMenu *>(menu->parentWidget());
}
// Now get the menu bar
QMenuBar *mbar = qobject_cast<QMenuBar *>(menu->parentWidget());
// Bail if parentWidget() is not a QMenuBar
//
if( mbar != NULL ){
// Check if this is main menu bar
QVariant v = qApp->property("mainWindow");
if(v.isValid()) {
QWidget *mainWindow = (QWidget *)(v.value<void *>());
if(mbar->parentWidget() == mainWindow) {
//QString menuName;
//QString cmdStr(kShelfMenuItemCmd);
QAction *a = whichAction == kMainAction ? this : this->optionBoxAction();
if(NULL != a) {
// gUIInventory->fullName(a, menuName);
//cmdStr.append(menuName);
// cmdStr.appendChar(kBackSlashDoubleQuote);
//theCommandEngine->executeCommand( cmdStr );
return true;
}
}
}
}
return false;
}
示例3: eventFilter
bool DlgExpressionInput::eventFilter(QObject *obj, QEvent *ev)
{
// if the user clicks on a widget different to this
if (ev->type() == QEvent::MouseButtonPress && obj != this) {
// Since the widget has a transparent background we cannot rely
// on the size of the widget. Instead, it must be checked if the
// cursor is on this or an underlying widget or outside.
if (!underMouse()) {
// if the expression fields context-menu is open do not close the dialog
QMenu* menu = qobject_cast<QMenu*>(obj);
if (menu && menu->parentWidget() == ui->expression) {
return false;
}
bool on = ui->expression->completerActive();
// Do this only if the completer is not shown
if (!on) {
qApp->removeEventFilter(this);
reject();
}
}
}
return false;
}