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

Method CreateWidgets

Modules/FormsUI/src/QmitkLinearScaleQuestionWidget.cpp:73–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71}
72
73void QmitkLinearScaleQuestionWidget::CreateWidgets()
74{
75 this->RemoveWidgets();
76
77 auto [from, to] = m_Question->GetRange();
78 auto [fromText, toText] = m_Question->GetRangeLabels();
79 int column = 0;
80
81 if (!fromText.empty())
82 {
83 auto fromLabel = new QLabel(QString::fromStdString(fromText));
84 m_Layout->addWidget(fromLabel, 1, column++, Qt::AlignRight);
85 }
86
87 for (int i = from; i <= to; ++i)
88 {
89 auto label = new QLabel(QString("%1").arg(i));
90
91 auto radioButton = new QRadioButton;
92 radioButton->setFixedWidth(radioButton->sizeHint().height());
93
94 m_Layout->addWidget(label, 0, column, Qt::AlignHCenter);
95 m_Layout->addWidget(radioButton, 1, column++, Qt::AlignHCenter);
96
97 m_ButtonGroup->addButton(radioButton, i);
98 }
99
100 if (!toText.empty())
101 {
102 auto toLabel = new QLabel(QString::fromStdString(toText));
103 m_Layout->addWidget(toLabel, 1, column++, Qt::AlignLeft);
104 }
105
106 if (m_Question->IsRequired())
107 return;
108
109 m_ClearButton = new QPushButton("Clear selection");
110 m_ClearButton->setFlat(true);
111 m_ClearButton->hide();
112
113 m_Layout->addWidget(m_ClearButton, 2, 0, 1, column, Qt::AlignRight);
114
115 connect(m_ClearButton, &QPushButton::clicked, this, &Self::OnClearButtonClicked);
116}
117
118void QmitkLinearScaleQuestionWidget::RemoveWidgets()
119{

Callers 1

SetQuestionMethod · 0.95

Calls 7

RemoveWidgetsMethod · 0.95
GetRangeLabelsMethod · 0.80
IsRequiredMethod · 0.80
QStringClass · 0.50
GetRangeMethod · 0.45
emptyMethod · 0.45
sizeHintMethod · 0.45

Tested by

no test coverage detected