Medical Imaging Interaction Toolkit  2024.06.99-60d9b802
Medical Imaging Interaction Toolkit
QmitkQuestionWidget Class Referenceabstract

Abstract base class for all types of question widgets used in a QmitkForm. More...

#include <QmitkQuestionWidget.h>

Inheritance diagram for QmitkQuestionWidget:
Collaboration diagram for QmitkQuestionWidget:

Public Member Functions

 QmitkQuestionWidget (QWidget *parent=nullptr)
 
 ~QmitkQuestionWidget () override
 
void SetRequirementVisible (bool visible)
 
void ShowRequirement ()
 
void HideRequirement ()
 
Pure virtual functions

QmitkQuestionWidget is an abstract base class. Derive from this class to add a widget for a certain type of Question and override the following pure virtual functions. Please read the full documentation for all of these functions to fully understand implications and requirements.

Do not forget to register any new question widget by calling mitk::Forms::UI::IQuestionWidgetFactory::Register() like it is done in this module's activator class.

See also
mitk::Forms::UI::IQuestionWidgetFactory
virtual QmitkQuestionWidgetCreateAnother (QWidget *parent=nullptr) const =0
 Create a new instance of the derived question widget class type. More...
 
virtual mitk::Forms::QuestionGetQuestion () const =0
 Get the question associated with this widget. More...
 
virtual void SetQuestion (mitk::Forms::Question *question)=0
 Initialize the widget based on the given question. More...
 
virtual void Reset ()=0
 Reset the state of the GUI as if no interaction would have been happened yet. More...
 

Protected Member Functions

void InsertLayout (QLayout *layout)
 Insert a layout containing all GUI elements specific to the derived question widget type. More...
 

Detailed Description

Abstract base class for all types of question widgets used in a QmitkForm.

This class manages GUI elements common to all questions like labels for the question text and a reminder that a response might be required. All specific GUI elements of derived classes must be put into a layout and inserted by calling InsertLayout().

Please make sure to read the full documentation of the pure virtual functions in particular to fully understand implications and requirements.

Definition at line 36 of file QmitkQuestionWidget.h.

Constructor & Destructor Documentation

◆ QmitkQuestionWidget()

QmitkQuestionWidget::QmitkQuestionWidget ( QWidget *  parent = nullptr)
explicit

◆ ~QmitkQuestionWidget()

QmitkQuestionWidget::~QmitkQuestionWidget ( )
override

Member Function Documentation

◆ CreateAnother()

virtual QmitkQuestionWidget* QmitkQuestionWidget::CreateAnother ( QWidget *  parent = nullptr) const
pure virtual

Create a new instance of the derived question widget class type.

This method is mainly used by mitk::Forms::UI::IQuestionWidgetFactory to create new instances from registered prototype instances.

QmitkQuestionWidget* QmitkRhetoricalQuestionWidget::CreateAnother(QWidget* parent) const
{
return new RhetoricalQuestionWidget(parent);
}

Implemented in QmitkMultipleChoiceQuestionWidget, QmitkScreenshotQuestionWidget, QmitkCheckboxesQuestionWidget, QmitkLinearScaleQuestionWidget, QmitkDropdownQuestionWidget, QmitkParagraphQuestionWidget, and QmitkShortAnswerQuestionWidget.

◆ GetQuestion()

virtual mitk::Forms::Question* QmitkQuestionWidget::GetQuestion ( ) const
pure virtual

Get the question associated with this widget.

Question* QmitkRhetoricalQuestionWidget::GetQuestion() const
{
// In class declaration: mitk::Forms::RhetoricalQuestion* m_Question;
return m_Question;
}
See also
SetQuestion()

Implemented in QmitkMultipleChoiceQuestionWidget, QmitkScreenshotQuestionWidget, QmitkCheckboxesQuestionWidget, QmitkLinearScaleQuestionWidget, QmitkDropdownQuestionWidget, QmitkParagraphQuestionWidget, and QmitkShortAnswerQuestionWidget.

◆ HideRequirement()

void QmitkQuestionWidget::HideRequirement ( )

◆ InsertLayout()

void QmitkQuestionWidget::InsertLayout ( QLayout *  layout)
protected

Insert a layout containing all GUI elements specific to the derived question widget type.

This method is typically called from the constructor of a derived class after all GUI elements have been set up and organized in a layout.

QmitkRhetoricalQuestionWidget::QmitkRhetoricalQuestionWidget(QWidget* parent)
m_Question(nullptr),
m_Layout(new QVBoxLayout),
m_Label(new QLabel)
{
m_Label->setText("You know the answer... we all do.");
m_Layout->addWidget(m_Label);
this->InsertLayout(m_Layout);
}

◆ Reset()

virtual void QmitkQuestionWidget::Reset ( )
pure virtual

Reset the state of the GUI as if no interaction would have been happened yet.

Note
It is required to call this base class method at the end of the derived method.
void QmitkRhetoricalQuestionWidget::Reset()
{
// It's a rhetorical question... nothing specific to be reset.
QmitkQuestionWidget::Reset(); // Nevertheless, this is required at the end!
}

Implemented in QmitkMultipleChoiceQuestionWidget, QmitkScreenshotQuestionWidget, QmitkCheckboxesQuestionWidget, QmitkLinearScaleQuestionWidget, QmitkDropdownQuestionWidget, QmitkParagraphQuestionWidget, and QmitkShortAnswerQuestionWidget.

◆ SetQuestion()

virtual void QmitkQuestionWidget::SetQuestion ( mitk::Forms::Question question)
pure virtual

Initialize the widget based on the given question.

This method is rarely used explicitly since it is automatically called by mitk::Forms::UI::IQuestionWidgetFactory::Create().

You are excepted to throw an mitk::Exception if the Question type does not match the expectations of the widget.

Note
It is required to call this base class method at the beginning of the derived method.
void QmitkRhetoricalQuestionWidget::SetQuestion(Question* question)
{
auto rhetoricalQuestion = dynamic_cast<RhetoricalQuestion*>(question);
if (rhetoricalQuestion == nullptr)
mitkThrow() << "QmitkRhetoricalQuestionWidget only accepts RhetoricalQuestion as question type!";
m_Question = rhetoricalQuestion;
}

Implemented in QmitkMultipleChoiceQuestionWidget, QmitkScreenshotQuestionWidget, QmitkCheckboxesQuestionWidget, QmitkLinearScaleQuestionWidget, QmitkDropdownQuestionWidget, QmitkParagraphQuestionWidget, and QmitkShortAnswerQuestionWidget.

◆ SetRequirementVisible()

void QmitkQuestionWidget::SetRequirementVisible ( bool  visible)

◆ ShowRequirement()

void QmitkQuestionWidget::ShowRequirement ( )

The documentation for this class was generated from the following file:
QmitkQuestionWidget::Reset
virtual void Reset()=0
Reset the state of the GUI as if no interaction would have been happened yet.
QmitkQuestionWidget
Abstract base class for all types of question widgets used in a QmitkForm.
Definition: QmitkQuestionWidget.h:36
QmitkQuestionWidget::SetQuestion
virtual void SetQuestion(mitk::Forms::Question *question)=0
Initialize the widget based on the given question.
mitkThrow
#define mitkThrow()
Definition: mitkExceptionMacro.h:27