Actions
Bug #11257
openValidator changes the order of signals
Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
01/17/2023
Due date:
% Done:
0%
Estimated time:
Description
I have a dialog window with LineEdit and a default button. If I change the text in LineEdit and then press the return key then the signal clicked is sent after the signal changed from LineEdit. But if a validator is set on LineEdit then the order in which signals are sent changes. Normally, Signal clicked is connected to the Dialog::accept slot. In this case the dialog window is destroyed before the signal changed is sent.
Here is an example:
auto layout = std::make_unique<Wt::WVBoxLayout>();
auto lineEdit1 = layout->addWidget(std::make_unique<Wt::WLineEdit>());
lineEdit1->changed().connect([]() {
int a = 0;
});
auto lineEdit2 = layout->addWidget(std::make_unique<Wt::WLineEdit>());
lineEdit2->setValidator(std::make_shared<Wt::WIntValidator>(0, 100));
lineEdit2->changed().connect([]() {
int a = 0;
});
auto dialog = std::make_unique<Wt::WDialog>("Dialog");
dialog->contents()->setLayout(std::move(layout));
auto button = std::make_unique<Wt::WPushButton>("Default");
button->setDefault(true);
button->clicked().connect([d = dialog.get()]() {
int a = 0;
//d->accept();
});
dialog->footer()->addWidget(std::move(button));
dialog->exec();
No data to display
Actions