Quote:
Originally Posted by KevinH
In the preferences, if I allow a two column list for users to put in numeric values in one column and a numeric entity or named entity in the other column, how can I validate what they input?
QTextDocument text;
text.setHtml("<>"");
QString plain = text.toPlainText();
|
This will work in most but not all cases. QTextDocument only uses a subset of HTML 4. I doubt it supports all entities.
My recommendation is to validate that the entity starts and ends with &;. If it's wrong it's wrong. You could provide an optional validation button that does the QTextDocument check and any that it can't validate it sets the background color of the line in error in yell letting the user know there is an issue with that one. If the basic (&
validation fails, don't allow saving and mark the line that failed in red.