Here's the combo box related code:
// Initizalize Y axis controls
<< "some"
<< "presets"
<< "here";
ui.cmbYAxis->setDuplicatesEnabled(false);
ui.cmbYAxis->addItems(mYScalePresets);
ui.cmbYAxis->insertSeparator(ui.cmbYAxis->count()); // Insert separator at the end
ui.cmbYAxis->setValidator(new ValuesRangeValidator(ui.cmbYAxis));
ui.
cmbYAxis->setInsertPolicy
(QComboBox::InsertAtBottom);
ui.cmbYAxis->setCurrentIndex(0);
// Initizalize Y axis controls
mYScalePresets = QStringList()
<< "some"
<< "presets"
<< "here";
ui.cmbYAxis->setDuplicatesEnabled(false);
ui.cmbYAxis->addItems(mYScalePresets);
ui.cmbYAxis->insertSeparator(ui.cmbYAxis->count()); // Insert separator at the end
ui.cmbYAxis->setValidator(new ValuesRangeValidator(ui.cmbYAxis));
ui.cmbYAxis->setInsertPolicy(QComboBox::InsertAtBottom);
ui.cmbYAxis->setCurrentIndex(0);
To copy to clipboard, switch view to plain text mode
I'lll clarify the two issues I have:
1. I want to see that the validator code is executed when I'm putting text in and clicking Enter.
2. The behavior I would eventually want to achieve is to interferen to at the point of leaving focus. I want to add the item to the combo if its text is valid.
Thanks again for your assistance.
Added after 20 minutes:
OK, I've found the reason for the 1st issue: and it did come down to the virtual method after all!
I've used the wrong signature:
// WRONG:
// QValidator::State validate(const QString &valueToValidate, int &pos);
// Correct:
// WRONG:
// QValidator::State validate(const QString &valueToValidate, int &pos);
// Correct:
QValidator::State validate(QString &valueToValidate, int &pos) const;
To copy to clipboard, switch view to plain text mode
But now I see that perhaps this whole approach is wrong for me because it would be very hard for me to code all the conditions for the "Intermediate" state. Can you try and help out with the 2nd issue?
Added after 22 minutes:
Another scenario that require an intervention point that I still don't know to find:
When manually entering data, to limit the amount of items (for example, if passed 10, remove the first).
Is there a solution I'm not seeing or does this require subclassing of the combobox?
Bookmarks