本文整理汇总了C++中QMenu::parent方法的典型用法代码示例。如果您正苦于以下问题:C++ QMenu::parent方法的具体用法?C++ QMenu::parent怎么用?C++ QMenu::parent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMenu
的用法示例。
在下文中一共展示了QMenu::parent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
/**
* View Menu
* Interface modification, load other interfaces, activate Extensions
* \param current, set to NULL for menu creation, else for menu update
**/
QMenu *VLCMenuBar::ViewMenu( intf_thread_t *p_intf, QMenu *current, MainInterface *_mi )
{
QAction *action;
QMenu *menu;
MainInterface *mi = _mi ? _mi : p_intf->p_sys->p_mi;
assert( mi );
if( !current )
{
menu = new QMenu( qtr( "&View" ), mi );
}
else
{
menu = current;
//menu->clear();
//HACK menu->clear() does not delete submenus
QList<QAction*> actions = menu->actions();
foreach( QAction *a, actions )
{
QMenu *m = a->menu();
if( a->parent() == menu ) delete a;
else menu->removeAction( a );
if( m && m->parent() == menu ) delete m;
}
}
示例2: menuHiding
void RibbonWidget::menuHiding()
{
QMenu *menu = qobject_cast<QMenu *>(this->sender());
RibbonButton *button = qobject_cast<RibbonButton *>(menu->parent());
qDebug() << button;
}
示例3: standardObjects
void tst_QScriptEngineDebugger::standardObjects()
{
#if defined(Q_OS_WINCE) && _WIN32_WCE < 0x600
QSKIP("skipped due to high mem usage until task 261062 is fixed", SkipAll);
#endif
QScriptEngine engine;
QScriptEngineDebugger debugger;
debugger.attachTo(&engine);
QMainWindow *win = debugger.standardWindow();
QCOMPARE(static_cast<QWidget *>(win->parent()), (QWidget*)0);
QMenu *menu = debugger.createStandardMenu();
QCOMPARE(static_cast<QWidget *>(menu->parent()), (QWidget*)0);
QToolBar *toolBar = debugger.createStandardToolBar();
QCOMPARE(static_cast<QWidget *>(toolBar->parent()), (QWidget*)0);
QMenu *menu2 = debugger.createStandardMenu(win);
QCOMPARE(static_cast<QWidget *>(menu2->parent()), (QWidget*)win);
QVERIFY(menu2 != menu);
QToolBar *toolBar2 = debugger.createStandardToolBar(win);
QCOMPARE(static_cast<QWidget *>(toolBar2->parent()), (QWidget*)win);
QVERIFY(toolBar2 != toolBar);
delete menu;
delete toolBar;
}
示例4: onCameraChangeAction
void QCastViewGL::onCameraChangeAction()
{
QAction *pAct = qobject_cast< QAction* >(QObject::sender());
if (!pAct) return;
QVariant v = pAct->data();
void* pc = v.value<void*>();
cogx::display::CDisplayCamera* pCamera = static_cast<cogx::display::CDisplayCamera*>(pc);
//std::cout << pAct << " " << pAct->text().toStdString() << " " << pc << " " << pCamera << std::endl;
if (pCamera) {
// TODO: should check if it is valid -- is it in getCameras()?
selectCamera(pCamera);
}
// Replace the action for the button.
// Parent hierarchy: action -> menu -> button
QMenu *pMenu = qobject_cast< QMenu* >(pAct->parent());
if (pMenu) {
QToolButton* pBut = qobject_cast< QToolButton* >(pMenu->parent());
if (pBut) {
QAction *pOldAct = pBut->defaultAction();
if (pOldAct && pOldAct->parent() == pAct->parent()) {
//std::cout << "Changing default action" << std::endl;
pBut->setDefaultAction(pAct);
}
}
}
}