PDA

View Full Version : How can I implement a dialog like Windows when I input an invalid file name?



quantity
19th October 2011, 11:29
Hi guys,

I'm a QT programmer, now I need to enable users to specify a name for an object in my program. There's a rule that the name can only contain several characters, and if user inputs an invalid character, I want to pop up a dialog to indicate the error, like Windows does (see the attached image). I have implemented a sub-class deriving from QRegExpValidator, and can successfully obtain the signal when it fails to validate. But how can I implement a dialog like this? Anyone has any idea about this?

Thanks in advance.7008

nish
19th October 2011, 11:34
It think QToolTip will do the trick for you

quantity
19th October 2011, 11:52
Can you explain the detail? I've tried QToolTip like this: lineEdit->setToolTip(tr("Please input valid characters")); but it doesn't work:(


It think QToolTip will do the trick for you

nish
19th October 2011, 14:08
show the tooltip when you get a signal from your QRegExpValidator using QToolTip::showText