本文整理汇总了C++中QToolBar::connect方法的典型用法代码示例。如果您正苦于以下问题:C++ QToolBar::connect方法的具体用法?C++ QToolBar::connect怎么用?C++ QToolBar::connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QToolBar
的用法示例。
在下文中一共展示了QToolBar::connect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getToolbars
void QCastViewGL::getToolbars(CPtrVector<QToolBar>& toolbars)
{
if (! pView) return;
CPtrVector<cogx::display::CDisplayCamera> cameras;
pView->getCameras(cameras);
if (cameras.size() < 1) return;
// pBar->parent will be reset in QViewContainer
QToolBar *pBar = new QToolBar(QString::fromStdString(pView->m_id), this);
if (pBar) {
unsigned int nc = cameras.size();
if (nc > 3) nc = 3;
cogx::display::CDisplayCamera* pCamera;
for (unsigned int i= 0; i < nc; i++) {
QToolButton *pBut = new QToolButton(pBar);
pCamera = cameras[i];
QString text = QString::fromStdString(pCamera->name);
QAction* pAct = new QAction(QIcon(":/toolButton/camera-photo.png"), text, pBut);
pAct->setToolTip("Select Camera: " + text);
pAct->setData(qVariantFromValue((void*)pCamera));
pBut->setDefaultAction(pAct);
pBar->addWidget(pBut);
pBar->connect(pAct, SIGNAL(triggered()), this, SLOT(onCameraChangeAction()));
// With more than 3 cameras things become complicated...
if (i == 2 && cameras.size() > 2) {
QAction *pPopAct;
QMenu *pMenu = new QMenu(pBut); // parent MUST be button, see onCameraChangeAction
pBut->setMenu(pMenu);
pBut->setPopupMode(QToolButton::MenuButtonPopup);
for (unsigned int j = 0; j < cameras.size(); j++) {
if (i == j) {
pMenu->addAction(pAct);
pAct->setParent(pMenu); // parent MUST be menu, see onCameraChangeAction
}
else {
pCamera = cameras[j];
text = QString::fromStdString(pCamera->name);
pPopAct = pMenu->addAction(QIcon(":/toolButton/camera-photo.png"), text);
pPopAct->setData(qVariantFromValue((void*)pCamera));
pPopAct->setToolTip("Select Camera: " + text);
pBar->connect(pPopAct, SIGNAL(triggered()), this, SLOT(onCameraChangeAction()));
}
}
if (0) {
text = "TODO: Configure camera buttons...";
pPopAct = pMenu->addAction(QIcon(":/toolButton/camera-photo.png"), text);
pBar->connect(pPopAct, SIGNAL(triggered()), this, SLOT(onActConfigureCameras()));
}
}
}
toolbars.push_back(pBar);
}
}