本文整理汇总了C++中QSignalMapper::mapping方法的典型用法代码示例。如果您正苦于以下问题:C++ QSignalMapper::mapping方法的具体用法?C++ QSignalMapper::mapping怎么用?C++ QSignalMapper::mapping使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSignalMapper
的用法示例。
在下文中一共展示了QSignalMapper::mapping方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sipConvertFromType
static PyObject *meth_QSignalMapper_mapping(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
int a0;
QSignalMapper *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "Bi", &sipSelf, sipType_QSignalMapper, &sipCpp, &a0))
{
QObject *sipRes;
Py_BEGIN_ALLOW_THREADS
sipRes = sipCpp->mapping(a0);
Py_END_ALLOW_THREADS
return sipConvertFromType(sipRes,sipType_QObject,NULL);
}
}
示例2: createUserMenu
QMenu* SimObjectWidget::createUserMenu() const
{
QMenu* menu = new QMenu(tr(&object == Simulation::simulation->scene ? "S&cene" : "&Object"));
QSignalMapper* flagsSignalMapper = new QSignalMapper(menu);
connect(flagsSignalMapper, SIGNAL(mapped(int)), SLOT(toggleRenderFlag(int)));
{
QMenu* subMenu = menu->addMenu(tr("&Drag and Drop"));
QAction* action = subMenu->menuAction();
action->setIcon(QIcon(":/Icons/DragPlane.png"));
action->setStatusTip(tr("Select the drag and drop dynamics mode and plane along which operations are performed"));
QActionGroup* actionGroup = new QActionGroup(subMenu);
QSignalMapper* signalMapper = new QSignalMapper(subMenu);
connect(signalMapper, SIGNAL(mapped(int)), SLOT(setDragPlane(int)));
action = subMenu->addAction(tr("X/Y Plane"));
actionGroup->addAction(action);
signalMapper->setMapping(action, SimRobotCore2::Renderer::xyPlane);
action->setShortcut(QKeySequence(Qt::Key_Z));
action->setCheckable(true);
connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
action = subMenu->addAction(tr("X/Z Plane"));
actionGroup->addAction(action);
signalMapper->setMapping(action, SimRobotCore2::Renderer::xzPlane);
action->setShortcut(QKeySequence(Qt::Key_Y));
action->setCheckable(true);
connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
action = subMenu->addAction(tr("Y/Z Plane"));
actionGroup->addAction(action);
signalMapper->setMapping(action, SimRobotCore2::Renderer::yzPlane);
action->setShortcut(QKeySequence(Qt::Key_X));
action->setCheckable(true);
connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
qobject_cast<QAction*>(signalMapper->mapping(objectRenderer.getDragPlane()))->setChecked(true);
subMenu->addSeparator();
actionGroup = new QActionGroup(subMenu);
signalMapper = new QSignalMapper(subMenu);
connect(signalMapper, SIGNAL(mapped(int)), SLOT(setDragMode(int)));
action = subMenu->addAction(tr("&Keep Dynamics"));
actionGroup->addAction(action);
signalMapper->setMapping(action, SimRobotCore2::Renderer::keepDynamics);
action->setShortcut(QKeySequence(Qt::Key_7));
action->setCheckable(true);
connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
action = subMenu->addAction(tr("&Reset Dynamics"));
actionGroup->addAction(action);
signalMapper->setMapping(action, SimRobotCore2::Renderer::resetDynamics);
action->setShortcut(QKeySequence(Qt::Key_8));
action->setCheckable(true);
connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
action = subMenu->addAction(tr("A&dopt Dynamics"));
actionGroup->addAction(action);
signalMapper->setMapping(action, SimRobotCore2::Renderer::adoptDynamics);
action->setShortcut(QKeySequence(Qt::Key_9));
action->setCheckable(true);
connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
action = subMenu->addAction(tr("&Apply Dynamics"));
actionGroup->addAction(action);
signalMapper->setMapping(action, SimRobotCore2::Renderer::applyDynamics);
action->setShortcut(QKeySequence(Qt::Key_0));
action->setCheckable(true);
connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
qobject_cast<QAction*>(signalMapper->mapping(objectRenderer.getDragMode()))->setChecked(true);
}
menu->addSeparator();
{
QMenu* subMenu = menu->addMenu(tr("&Camera"));
QAction* action = subMenu->menuAction();
action->setIcon(QIcon(":/Icons/camera.png"));
action->setStatusTip(tr("Select different camera modes for displaying the scene"));
QActionGroup* actionGroup = new QActionGroup(subMenu);
QSignalMapper* signalMapper = new QSignalMapper(subMenu);
connect(signalMapper, SIGNAL(mapped(int)), SLOT(setCameraMode(int)));
action = subMenu->addAction(tr("&Target Mode"));
action->setCheckable(true);
actionGroup->addAction(action);
signalMapper->setMapping(action, SimRobotCore2::Renderer::targetCam);
connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
action = subMenu->addAction(tr("&Free Mode"));
action->setCheckable(true);
actionGroup->addAction(action);
signalMapper->setMapping(action, SimRobotCore2::Renderer::freeCam);
connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
qobject_cast<QAction*>(signalMapper->mapping(objectRenderer.getCameraMode()))->setChecked(true);
subMenu->addSeparator();
action = subMenu->addAction(tr("&Reset"));
action->setShortcut(QKeySequence(Qt::Key_R));
connect(action, SIGNAL(triggered()), this, SLOT(resetCamera()));
action = subMenu->addAction(tr("&Toggle"));
action->setShortcut(QKeySequence(Qt::Key_T));
connect(action, SIGNAL(triggered()), this, SLOT(toggleCameraMode()));
/*
action = subMenu->addAction(tr("&Fit"));
action->setShortcut(QKeySequence(Qt::Key_F));
connect(action, SIGNAL(triggered()), this, SLOT(fitCamera()));
subMenu->addSeparator();
//.........这里部分代码省略.........
示例3: createPopupMenu
QMenu* ObjectWidget::createPopupMenu()
{
QMenu* menu = new QMenu(tr("&Object"));
QAction* action;
action = menu->addAction(QIcon(":/icons/page_copy.png"), tr("&Copy"));
action->setShortcut(QKeySequence(QKeySequence::Copy));
action->setStatusTip(tr("Copy the current selection's contents or view to the clipboard"));
connect(action, SIGNAL(triggered()), this, SLOT(copy()));
menu->addSeparator();
QMenu* subMenu = menu->addMenu(tr("&Drag and Drop"));
action = subMenu->menuAction();
action->setIcon(QIcon(":/icons/DragPlane.png"));
action->setStatusTip(tr("Select the drag and drop dynamics mode and plane along which operations are performed"));
QActionGroup* actionGroup = new QActionGroup(subMenu);
QSignalMapper* signalMapper = new QSignalMapper(subMenu);
connect(signalMapper, SIGNAL(mapped(int)), SLOT(setDragPlane(int)));
action = subMenu->addAction(tr("X/Y Plane"));
actionGroup->addAction(action);
signalMapper->setMapping(action, XY_PLANE);
action->setShortcut(QKeySequence(Qt::Key_Z));
action->setCheckable(true);
connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
action = subMenu->addAction(tr("X/Z Plane"));
actionGroup->addAction(action);
signalMapper->setMapping(action, XZ_PLANE);
action->setShortcut(QKeySequence(Qt::Key_Y));
action->setCheckable(true);
connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
action = subMenu->addAction(tr("Y/Z Plane"));
actionGroup->addAction(action);
signalMapper->setMapping(action, YZ_PLANE);
action->setShortcut(QKeySequence(Qt::Key_X));
action->setCheckable(true);
connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
qobject_cast<QAction*>(signalMapper->mapping(objectRenderer.getDragPlane()))->setChecked(true);
subMenu->addSeparator();
actionGroup = new QActionGroup(subMenu);
signalMapper = new QSignalMapper(subMenu);
connect(signalMapper, SIGNAL(mapped(int)), SLOT(setDragMode(int)));
action = subMenu->addAction(tr("&Keep Dynamics"));
actionGroup->addAction(action);
signalMapper->setMapping(action, KEEP_DYNAMICS);
action->setShortcut(QKeySequence(Qt::Key_8));
action->setCheckable(true);
connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
action = subMenu->addAction(tr("&Reset Dynamics"));
actionGroup->addAction(action);
signalMapper->setMapping(action, RESET_DYNAMICS);
action->setShortcut(QKeySequence(Qt::Key_9));
action->setCheckable(true);
connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
action = subMenu->addAction(tr("&Apply Dynamics"));
actionGroup->addAction(action);
signalMapper->setMapping(action, APPLY_DYNAMICS);
action->setShortcut(QKeySequence(Qt::Key_0));
action->setCheckable(true);
connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
qobject_cast<QAction*>(signalMapper->mapping(objectRenderer.getDragMode()))->setChecked(true);
menu->addSeparator();
subMenu = menu->addMenu(tr("&Camera"));
action = subMenu->menuAction();
action->setIcon(QIcon(":/icons/camera.png"));
action->setStatusTip(tr("Select different camera modes for displaying the scene"));
actionGroup = new QActionGroup(subMenu);
signalMapper = new QSignalMapper(subMenu);
connect(signalMapper, SIGNAL(mapped(int)), SLOT(setCameraMode(int)));
action = subMenu->addAction(tr("&Target Mode"));
action->setCheckable(true);
actionGroup->addAction(action);
signalMapper->setMapping(action, VisualizationParameterSet::TARGETCAM);
connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
action = subMenu->addAction(tr("&Free Mode"));
action->setCheckable(true);
actionGroup->addAction(action);
signalMapper->setMapping(action, VisualizationParameterSet::FREECAM);
connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
action = subMenu->addAction(tr("&Presentation Mode"));
action->setCheckable(true);
actionGroup->addAction(action);
signalMapper->setMapping(action, VisualizationParameterSet::PRESENTATION);
connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
qobject_cast<QAction*>(signalMapper->mapping(objectRenderer.getCameraMode()))->setChecked(true);
subMenu->addSeparator();
action = subMenu->addAction(tr("&Reset"));
action->setShortcut(QKeySequence(Qt::Key_R));
connect(action, SIGNAL(triggered()), this, SLOT(resetCamera()));
action = subMenu->addAction(tr("&Toggle"));
action->setShortcut(QKeySequence(Qt::Key_T));
connect(action, SIGNAL(triggered()), this, SLOT(toggleCameraMode()));
action = subMenu->addAction(tr("&Fit"));
action->setShortcut(QKeySequence(Qt::Key_F));
connect(action, SIGNAL(triggered()), this, SLOT(fitCamera()));
subMenu->addSeparator();
action = subMenu->addAction(tr("&Snap To Root"));
action->setCheckable(true);
action->setChecked(objectRenderer.hasSnapToRoot());
//.........这里部分代码省略.........
示例4: createPluginHost
//.........这里部分代码省略.........
mapperCreatePluginHost->setMapping(bottomButton, NewSplitterBottom);
QObject::connect(mapperCreatePluginHost, SIGNAL(mapped(int)), SLOT(createPluginHost(int)));
//load plugin signal:
QObject::connect(addPluginWidgetButton, SIGNAL(clicked()), m_mapperLoadNewPlugin, SLOT(map()));
m_mapperLoadNewPlugin->setMapping(addPluginWidgetButton, pluginHost);
//close plugin host signal:
QObject::connect(closeButton, SIGNAL(clicked()), m_mapperClosePluginHost, SLOT(map()));
m_mapperClosePluginHost->setMapping(closeButton, pluginHost);
//create plugin switch signalmapper
QSignalMapper *mapperSwitchPlugin = new QSignalMapper(pluginHost);
mapperSwitchPlugin->setObjectName("rackPluginSwitchMapper");
QObject::connect(mapperSwitchPlugin, SIGNAL(mapped(QWidget *)), pluginStack, SLOT(setCurrentWidget(QWidget *)));
////test show/hide plugin widget
////QObject::connect(mapperSwitchPlugin, SIGNAL(mapped(QWidget *)), this, SLOT(showHidePluginWidget(QWidget*)));
//////
//create plugin toolbar for mainwindow
QToolBar *pluginToolBar = new QToolBar;
pluginToolBar->setObjectName("rackPluginToolBar");
pluginToolBar->setMovable(false);
pluginToolBar->hide();
addToolBar(Qt::BottomToolBarArea, pluginToolBar);
//store the toolbar pointer as dynamic property to access later when creating plugin toolbar buttons
pluginHost->setProperty("pluginToolBar", qVariantFromValue((QWidget *)pluginToolBar));
//plugin bar signals & slots:
QObject::connect(this, SIGNAL(enterSettingsMode()), pluginToolBar, SLOT(hide()));
QObject::connect(this, SIGNAL(leaveSettingsMode()), pluginToolBar, SLOT(show()));
//insert new pluginhost widget in splitter, create new splitter if necessary
if (position == 0)
{
m_mainSplitter->addWidget(pluginHost);
return;
}
QSignalMapper *sm = qobject_cast<QSignalMapper *>(sender());
QWidget *senderPluginHost = qobject_cast<QWidget *>(sm->mapping(position)->parent()->parent());
RSplitter *parentSplitter = qobject_cast<RSplitter *>(senderPluginHost->parent());
QList<int> widgetsizes;
int senderpos = parentSplitter->indexOf(senderPluginHost);
int newposition;
if ((position == NewSplitterLeft) or (position == NewSplitterTop)) newposition = senderpos;
else newposition = senderpos + 1;
switch (position + parentSplitter->orientation()) { //horizontal=1 vertical=2
case 0: //left horizontal / top vertical
case 2: //right horizontal
case 4: //bottom vertical
widgetsizes = parentSplitter->sizes();
widgetsizes.replace(senderpos, int(widgetsizes.at(senderpos)/2));
widgetsizes.insert(senderpos + 1, widgetsizes.at(senderpos));
parentSplitter->insertWidget(newposition, pluginHost);
parentSplitter->setSizes(widgetsizes);
break;
case 1: //left vertical
case 3: //right vertical / bottom horizontal
case -1: //top horizontal
if (parentSplitter->count() == 1)
{
parentSplitter->setOrientation(Qt::Orientation(abs(position)));
widgetsizes = parentSplitter->sizes();
widgetsizes.replace(0, int(widgetsizes.at(0)/2));
widgetsizes.append(widgetsizes.at(0));
parentSplitter->insertWidget(newposition, pluginHost);
parentSplitter->setSizes(widgetsizes);
}
else if (parentSplitter->count() > 1)
{
RSplitter *newSplitter = new RSplitter(Qt::Orientation(abs(position)));
QObject::connect(this, SIGNAL(enterSettingsMode()), newSplitter, SIGNAL(enterSettingsMode()));
QObject::connect(this, SIGNAL(leaveSettingsMode()), newSplitter, SIGNAL(leaveSettingsMode()));
widgetsizes = parentSplitter->sizes();
parentSplitter->insertWidget(parentSplitter->indexOf(senderPluginHost), newSplitter);
newSplitter->addWidget(senderPluginHost);
QList<int> newsizes = newSplitter->sizes();
newsizes.replace(0, int(newsizes.at(0)/2));
newsizes.append(newsizes.at(0));
if ((position == NewSplitterLeft) or (position == NewSplitterTop)) newSplitter->insertWidget(0, pluginHost);
else newSplitter->addWidget(pluginHost);
newSplitter->setSizes(newsizes);
parentSplitter->setSizes(widgetsizes);
}
break;
}
}