/** * 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; } }
void RibbonWidget::menuHiding() { QMenu *menu = qobject_cast<QMenu *>(this->sender()); RibbonButton *button = qobject_cast<RibbonButton *>(menu->parent()); qDebug() << button; }
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; }
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); } } } }