MCPcopy Create free account
hub / github.com/PlotJuggler/PlotJuggler / addButton

Method addButton

pj_widgets/src/MessageBox.cpp:184–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

182}
183
184QPushButton* MessageBox::addButton(const QString& label, ButtonRole role) {
185 auto* btn = new QPushButton(label, this);
186 btn->setObjectName(QStringLiteral("pjMessageBoxButton"));
187 btn->setProperty("msgbox_role", QLatin1String(roleToToken(role)));
188 // Disable autoDefault so Enter doesn't trigger a non-primary button just
189 // because focus traversed onto it. The primary button still receives
190 // default-button focus.
191 btn->setAutoDefault(false);
192 btn->setDefault(role == kPrimaryRole);
193
194 const int index = static_cast<int>(buttons_.size());
195 buttons_.append(btn);
196 button_roles_.append(role);
197 button_labels_.append(label); // un-wrapped original; see rewrapButtonLabels()
198 button_column_->addWidget(btn);
199
200 QObject::connect(btn, &QPushButton::clicked, this, [this, index]() {
201 clicked_index_ = index;
202 accept();
203 });
204 return btn;
205}
206
207int MessageBox::clickedIndex() const {
208 return clicked_index_;

Callers 13

informationMethod · 0.80
warningMethod · 0.80
criticalMethod · 0.80
questionMethod · 0.80
DateRangePickerMethod · 0.80
TESTFunction · 0.80
TESTFunction · 0.80
applyTableRadioColumnFunction · 0.80
TESTFunction · 0.80
beginLoadMethod · 0.80
MainWindowMethod · 0.80
buildLocalToolbarMethod · 0.80

Calls 3

roleToTokenFunction · 0.85
sizeMethod · 0.45
appendMethod · 0.45

Tested by 3

TESTFunction · 0.64
TESTFunction · 0.64
TESTFunction · 0.64