Important: Please read the Qt Code of Conduct -

How to get semicolon in a QLineEdit's validation input mask?

  • Howdy folks,

    I've got a QLineEdit that I'm using to represent a SMPTE timecode. For 24fps, 25fps and 30fps (non-drop frame) the timecode represented as a string would be "<hours>:<minutes>:<seconds>:<frames>". For example, "01:22:05:17". For 29.97fps (drop frame), a semicolon is typically used between the seconds and frames, for example: "03:17:21;12".

    In my QLineEdit subclass I'm setting the validation input mask to "99:99:99:99" for non-drop frame timecodes and "99:99:99;99" for drop frame timecodes. The non-drop frame one works exactly as I want, but having the semicolon in the pattern for the drop-frame one is a problem. As documented here a semicolon is used to specify what character to use for blanks, with the blank character to follow the semicolon. With my drop-frame input mask of "99:99:99;99" it's a mess - I get tons of 9's when editing (blanks) and valid, drop-frame timecodes only display HH:MM:SS (ie no frames). How can I get a semicolon to work like "any other character"? I've tried escaping the semicolon with \ like the doc says to do for the other special characters with no luck. Any ideas?

    Many thanks,


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    AFAIK, you're out of luck on this one. The semi-colon is hardcoded deep down in a private class. You can try and change that but this means that you will have to build Qt yourself

  • Ahh, darn it. Oh well. I suppose I can make do with a dot instead of the semicolon, which is apparently also acceptable (according to SMPTE). Thanks for the response, SGaist!

  • Lifetime Qt Champion

    You're welcome !
    One thing you could do is create a feature request (but first check if somebody already asked for it) to add an API that allows to change that symbol

Log in to reply