MCPcopy Create free account
hub / github.com/MITK/MITK / CreateWidgets

Method CreateWidgets

Modules/FormsUI/src/QmitkMultipleChoiceQuestionWidget.cpp:78–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76}
77
78void QmitkMultipleChoiceQuestionWidget::CreateWidgets()
79{
80 this->RemoveWidgets();
81
82 int row = 0;
83
84 for (const auto& option : m_Question->GetOptions())
85 {
86 auto optionRadioButton = new QRadioButton(QString::fromStdString(option));
87 m_Layout->addWidget(optionRadioButton, row, 0, 1, 2);
88 m_ButtonGroup->addButton(optionRadioButton, row++);
89 }
90
91 if (m_Question->HasOtherOption())
92 {
93 auto otherRadioButton = new QRadioButton("Other:");
94 m_Layout->addWidget(otherRadioButton, row, 0);
95 m_ButtonGroup->addButton(otherRadioButton, row);
96 m_OtherId = row;
97
98 m_OtherLineEdit = new QLineEdit;
99 m_Layout->addWidget(m_OtherLineEdit, row++, 1);
100
101 connect(m_OtherLineEdit, &QLineEdit::textEdited, this, &Self::OnTextEdited);
102 connect(m_OtherLineEdit, &QLineEdit::editingFinished, this, &Self::OnEditingFinished);
103 }
104 else
105 {
106 m_OtherId = -1;
107 }
108
109 if (m_Question->IsRequired())
110 return;
111
112 m_ClearButton = new QPushButton("Clear selection");
113 m_ClearButton->setFlat(true);
114 m_ClearButton->hide();
115
116 m_Layout->addWidget(m_ClearButton, row, 0, 1, 2, Qt::AlignRight);
117
118 connect(m_ClearButton, &QPushButton::clicked, this, &Self::OnClearButtonClicked);
119}
120
121void QmitkMultipleChoiceQuestionWidget::RemoveWidgets()
122{

Callers 1

SetQuestionMethod · 0.95

Calls 4

RemoveWidgetsMethod · 0.95
HasOtherOptionMethod · 0.80
IsRequiredMethod · 0.80
GetOptionsMethod · 0.45

Tested by

no test coverage detected