-
I wanted to access the functions in
qSlicerApplication
andqSlicerLayoutManager
inqMRMLThreeDViewControllerWidget
class. -
when a Button in
qMRMLThreeDViewControllerWidget
is clicked an actionViewLayoutOneUp3DAction
should be triggred. -
Includes:
#include "../../../Base/QTGUI/qSlicerApplication.h"
#include "../../../Base/QTGUI/qSlicerLayoutManager.h"
- code for QToolButton in
qMRMLThreeDViewControllerWidget.cxx
:
void qMRMLThreeDViewControllerWidgetPrivate::init()
{
Q_Q(qMRMLThreeDViewControllerWidget);
this->Superclass::init();
q->setupMenuActions();
this->CenterToolButton = new QToolButton(q);
this->CenterToolButton->setAutoRaise(true);
this->CenterToolButton->setDefaultAction(this->ViewLayoutOneUp3DAction);
this->CenterToolButton->setFixedSize(15, 15);
this->BarLayout->insertWidget(2, this->CenterToolButton);
}
void qMRMLThreeDViewControllerWidget::setupMenuActions() {
Q_D(qMRMLThreeDViewControllerWidget);
d->ViewLayoutOneUp3DAction->setData(vtkMRMLLayoutNode::SlicerLayoutOneUp3DView);
}
void qMRMLThreeDViewControllerWidgetPrivate::setupPopupUi()
{
Q_Q(qMRMLThreeDViewControllerWidget);
this->Superclass::setupPopupUi();
QObject::connect(this->ViewLayoutOneUp3DAction, SIGNAL(triggered(QAction*)),
q, SLOT(ThreeDViewOnly(QAction*)));
}
void qMRMLThreeDViewControllerWidget::ThreeDViewOnly(QAction* action)
{
this->setLayout(action->data().toInt());
}
void qMRMLThreeDViewControllerWidget::setLayout(int layout)
{
qSlicerApplication::application()->layoutManager()->setLayout(layout);
}
- Declaration in
qMRMLThreeDViewControllerWidget.h
:
Public slots:
virtual void ThreeDViewOnly(QAction* action);
virtual void setLayout(int);
protected:
virtual void setupMenuActions();
- Error encountered:
![Screenshot (326)|690x153](upload://eRFkvTJKPRV2gd3jRz8SeWJR7VS.png)