当前位置: 首页>>代码示例>>C++>>正文


C++ QAction::parent方法代码示例

本文整理汇总了C++中QAction::parent方法的典型用法代码示例。如果您正苦于以下问题:C++ QAction::parent方法的具体用法?C++ QAction::parent怎么用?C++ QAction::parent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QAction的用法示例。


在下文中一共展示了QAction::parent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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);
         }
      }
   }
}
开发者ID:mmahnic,项目名称:cogx-display-server,代码行数:28,代码来源:QCastViewGL.cpp

示例2: setFormWindow

void ActionEditor::setFormWindow( FormWindow *fw )
{
    listActions->clear();
    formWindow = fw;
    if ( !formWindow ||
	 !::qt_cast<QMainWindow*>(formWindow->mainContainer()) ) {
	setEnabled( FALSE );
    } else {
	setEnabled( TRUE );
	for ( QAction *a = formWindow->actionList().first(); a; a = formWindow->actionList().next() ) {
	    ActionItem *i = 0;
	    if ( ::qt_cast<QAction*>(a->parent()) )
		continue;
	    i = new ActionItem( listActions, a );
	    i->setText( 0, a->name() );
	    i->setPixmap( 0, a->iconSet().pixmap() );
	    // make sure we don't duplicate the connection
 	    QObject::disconnect( a, SIGNAL( destroyed( QObject * ) ),
 				 this, SLOT( removeConnections( QObject * ) ) );
	    QObject::connect( a, SIGNAL( destroyed( QObject * ) ),
			      this, SLOT( removeConnections( QObject* ) ) );
	    if ( ::qt_cast<QActionGroup*>(a) ) {
		insertChildActions( i );
	    }
	}
	if ( listActions->firstChild() ) {
	    listActions->setCurrentItem( listActions->firstChild() );
	    listActions->setSelected( listActions->firstChild(), TRUE );
	}
    }
}
开发者ID:serghei,项目名称:kde3-kdevelop,代码行数:31,代码来源:actioneditorimpl.cpp

示例3: doEnableGLFilter

void ccViewer::doEnableGLFilter()
{
	if (!m_glWindow)
	{
		ccLog::Warning("[GL filter] No active 3D view!");
		return;
	}

	QAction *action = qobject_cast<QAction*>(sender());
	if (!action)
		return;
	ccGLFilterPluginInterface* ccPlugin = qobject_cast<ccGLFilterPluginInterface*>(action->parent());
	if (!ccPlugin)
		return;

	assert(ccPlugin->getType() == CC_GL_FILTER_PLUGIN);

	ccGlFilter* filter = ccPlugin->getFilter();
	if (filter)
	{
		if (m_glWindow->areGLFiltersEnabled())
		{
			m_glWindow->setGlFilter(filter);
			ccLog::Print("Note: go to << Display > Shaders & Filters > No filter >> to disable GL filter");
		}
		else
			ccLog::Error("GL filters not supported!");
	}
	else
	{
		ccLog::Error("Can't load GL filter (an error occurred)!");
	}
}
开发者ID:NUAAXQ,项目名称:trunk,代码行数:33,代码来源:ccviewer.cpp

示例4: onExecMiscAction

void LteMainWindow::onExecMiscAction()
{
    QAction *action = qobject_cast<QAction*>(sender());
    MiscInterface *ifMisc = qobject_cast<MiscInterface*>(action->parent());

    ifMisc->onExec(this);
}
开发者ID:zhenggao2,项目名称:ltetoolset2,代码行数:7,代码来源:lte_main_window.cpp

示例5: onExecLteAction

void LteMainWindow::onExecLteAction()
{
    QAction *action = qobject_cast<QAction*>(sender());
    LteInterface *ifLte = qobject_cast<LteInterface*>(action->parent());

    ifLte->onExec(this);
}
开发者ID:zhenggao2,项目名称:ltetoolset2,代码行数:7,代码来源:lte_main_window.cpp

示例6: insertWidget

void tst_QToolBar::insertWidget()
{
    QToolBar tb;
    QWidget w(&tb);

    QAction action1(0);
    QAction action2(0);

    tb.addAction(&action1);
    tb.addAction(&action2);
    QAction *widget = tb.insertWidget(&action2, &w);

    QCOMPARE(tb.actions().count(), 3);
    QCOMPARE(tb.actions()[0], &action1);
    QCOMPARE(tb.actions()[1], widget);
    QCOMPARE(tb.actions()[2], &action2);

    // it should be possible to reuse the action returned by
    // addWidget() to place the widget somewhere else in the toolbar
    tb.removeAction(widget);
    QCOMPARE(tb.actions().count(), 2);
    QCOMPARE(tb.actions()[0], &action1);
    QCOMPARE(tb.actions()[1], &action2);

    tb.insertAction(&action1, widget);
    QCOMPARE(tb.actions().count(), 3);
    QCOMPARE(tb.actions()[0], widget);
    QCOMPARE(tb.actions()[1], &action1);
    QCOMPARE(tb.actions()[2], &action2);

    tb.clear();
    QCOMPARE(tb.actions().count(), 0);

    {
        QToolBar tb;
        QPointer<QWidget> widget = new QWidget;
        QAction *action = tb.addWidget(widget);
        QVERIFY(action->parent() == &tb);

        QToolBar tb2;
        tb.removeAction(action);
        tb2.addAction(action);
        QVERIFY(widget && widget->parent() == &tb2);
        QVERIFY(action->parent() == &tb2);
    }
}
开发者ID:PNIDigitalMedia,项目名称:emscripten-qt,代码行数:46,代码来源:tst_qtoolbar.cpp

示例7: editSelectedFilterParameters

void FilterScriptDialog::editSelectedFilterParameters()
{
	//get the selected item
	int currentRow = ui->scriptListWidget->currentRow();	
	
	//return if no row was selected
	if(currentRow == -1)
		return;
	
	QString actionName = scriptPtr->actionList.at(currentRow).first;
	RichParameterSet oldParameterSet = scriptPtr->actionList.at(currentRow).second;
	
	//get the main window
	MainWindow *mainWindow = qobject_cast<MainWindow*>(parentWidget());
	
	if(NULL == mainWindow){
		qDebug() << "problem casting parent of filterscriptdialog to main window";
		return;
	}

	//get a pointer to this action and filter from the main window so we can get the 
	//description of the parameters from the filter
	QAction *action = mainWindow->pluginManager().actionFilterMap[actionName];
	MeshFilterInterface *iFilter = qobject_cast<MeshFilterInterface *>(action->parent());
	
	if(NULL == iFilter){
		qDebug() << "null filter";
		return;
	}

	//fill the paramter set with all the names and descriptions which are lost in the 
	//filter script
	RichParameterSet newParameterSet;
	iFilter->initParameterSet(action, mainWindow->GLA()->meshDoc, newParameterSet);

	if(newParameterSet.paramList.size() == oldParameterSet.paramList.size())
	{
		//now set values to be the old values
		RichParameterCopyConstructor cc;
		for(int i = 0; i < newParameterSet.paramList.size(); i++)
		{
			oldParameterSet.paramList[i]->accept(cc);
			newParameterSet.paramList[i]->val = cc.lastCreated->val;
		}	
	} else
		qDebug() << "the size of the given list is not the same as the filter suggests it should be.  your filter script may be out of date, or there is a bug in the filter script class";

	//launch the dialog
	GenericParamDialog parameterDialog(this, &newParameterSet, "Edit Parameters", &mainWindow->GLA()->meshDoc);
	int result = parameterDialog.exec();
	if(result == QDialog::Accepted){
		//keep the changes	
		scriptPtr->actionList[currentRow].second = newParameterSet;
	}
	
}
开发者ID:Booley,项目名称:nbis,代码行数:56,代码来源:filterScriptDialog.cpp

示例8: remove_pony

void ConfigWindow::remove_pony()
{
    // Get a pointer to Pony from sender()
    QAction *q = qobject_cast<QAction*>(QObject::sender());
    Pony* p = static_cast<Pony*>(q->parent()->parent()); // QAction->QMenu->QMainWindow(Pony)
    ponies.remove(p->get_shared_ptr());

    save_settings();
    update_active_list();
}
开发者ID:rudy132,项目名称:qt-ponies,代码行数:10,代码来源:configwindow.cpp

示例9: editorCancel

void ItemDelegate::editorCancel()
{
    QAction *action = qobject_cast<QAction*>( sender() );
    Q_ASSERT(action != NULL);
    QObject *parent = action->parent();
    Q_ASSERT(parent != NULL);
    QPlainTextEdit *editor = qobject_cast<QPlainTextEdit*>( parent->parent() );
    Q_ASSERT(editor != NULL);

    emit closeEditor(editor, QAbstractItemDelegate::RevertModelCache);
}
开发者ID:libbkmz,项目名称:CopyQ,代码行数:11,代码来源:itemdelegate.cpp

示例10: editorSave

void ItemDelegate::editorSave()
{
    QAction *action = qobject_cast<QAction*>( sender() );
    Q_ASSERT(action != NULL);
    QObject *parent = action->parent();
    Q_ASSERT(parent != NULL);
    QPlainTextEdit *editor = qobject_cast<QPlainTextEdit*>( parent->parent() );
    Q_ASSERT(editor != NULL);

    emit commitData(editor);
    emit closeEditor(editor);
}
开发者ID:libbkmz,项目名称:CopyQ,代码行数:12,代码来源:itemdelegate.cpp

示例11: remove_pony_all

void ConfigWindow::remove_pony_all()
{
    // Get a pointer to Pony from sender()
    QAction *q = qobject_cast<QAction*>(QObject::sender());
    Pony* p = static_cast<Pony*>(q->parent()->parent()); // QAction->QMenu->QMainWindow(Pony)
    QString pony_name(p->name); // We must copy the name, because it will be deleted
    ponies.remove_if([&pony_name](const std::shared_ptr<Pony> &pony) {
        return pony->name == pony_name;
    });

    save_settings();
    update_active_list();
}
开发者ID:rudy132,项目名称:qt-ponies,代码行数:13,代码来源:configwindow.cpp

示例12: foldedChanged

void
LauncherContextualMenu::setFolded(int folded)
{
    if (folded == m_folded) {
        return;
    }

    if (folded) {
        /* Remove all actions but the title. */
        for (int i = actions().size(); i > 0; --i) {
            QAction* action = actions().at(i - 1);
            if (action != m_titleAction) {
                removeAction(action);
                if (action->parent() == this) {
                    /* Delete the action only if we "own" it,
                       otherwise let its parent take care of it. */
                    delete action;
                }
            }
        }
    } else {
        int prevWidth = width();
        int left = x(), top = y();
        addSeparator();
        m_launcherItem->createMenuActions();

        QRect screenGeometry = QApplication::desktop()->screenGeometry(this);
        if (QApplication::isRightToLeft()) {
            left -= width() - prevWidth;
        }
        if (height() <= screenGeometry.height()) {
            /* Adjust the position of the menu only if it fits entirely on the screen. */
            int menuBottomEdge = y() + height();
            int screenBottomEdge = screenGeometry.y() + screenGeometry.height();
            if (menuBottomEdge > screenBottomEdge) {
                /* The menu goes offscreen, shift it upwards. */
                m_arrowY += menuBottomEdge - screenBottomEdge;
                top = screenBottomEdge - height();
            }
        }
        move(left, top);
        if (!transparencyAvailable()) {
            /* The arrow has moved relatively to the menu. */
            updateMask();
        }
    }

    m_folded = folded;

    Q_EMIT foldedChanged(m_folded);
}
开发者ID:ManoharUpputuri,项目名称:unity-2d,代码行数:51,代码来源:launchermenu.cpp

示例13: qDebug

void MainWindow2::exportFile()
{
    QAction* action = qobject_cast<QAction*>(sender());
    ExportInterface* exportPlugin = qobject_cast<ExportInterface*>(action->parent());
    if (exportPlugin)
    {
        //exportPlugin->exportFile();
    }
    else
    {
        qDebug() << "exportPlugin is null";
    }
    //const QImage image = iFilter->filterImage(action->text(), paintArea->image(), this);
    //paintArea->setImage(image);
}
开发者ID:wesen,项目名称:pencil,代码行数:15,代码来源:mainwindow2.cpp

示例14: sl_plusClicked

void CollocationsDialogController::sl_plusClicked() {
    if (task != NULL) {
        return;
    }
    QMenu m;
    AnnotationSettingsRegistry* asr = AppContext::getAnnotationsSettingsRegistry();
    foreach(const QString& name, allNames) {
        if (usedNames.contains(name)) {
            continue;
        }
        QColor c = asr->getAnnotationSettings(name)->color;
        QAction* a = m.addAction(GUIUtils::createSquareIcon(c, 10), name, this, SLOT(sl_addName()));
        assert(a->parent() == &m); Q_UNUSED(a);
    }
    if (m.isEmpty()) {
        m.addAction(tr("No annotations left"));
    }
    m.exec(QCursor::pos());
}
开发者ID:ugeneunipro,项目名称:ugene-old,代码行数:19,代码来源:CollocationsDialogController.cpp

示例15: contextMenuAction

void ClipboardBrowser::contextMenuAction()
{
    QAction *act = qobject_cast<QAction *>(sender());
    Q_ASSERT(act != NULL);

    QVariant actionData = act->data();
    Q_ASSERT( actionData.isValid() );

    int i = actionData.toInt();
    if (i < 0 || i >= m_sharedData->commands.size())
        return;

    Command cmd = m_sharedData->commands[i];
    if ( cmd.outputTab.isEmpty() )
        cmd.outputTab = m_id;

    bool isContextMenuAction = act->parent() == m_menu;
    if (isContextMenuAction && cmd.transform) {
        foreach (const QModelIndex &index, selectedIndexes())
            emit requestActionDialog(*itemData(index.row()), cmd, index);
    } else {
开发者ID:pmros,项目名称:CopyQ,代码行数:21,代码来源:clipboardbrowser.cpp


注:本文中的QAction::parent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。