PDA

View Full Version : Making qApp->beep from QIntValidator being false



duave
9th September 2010, 07:42
Hi,

I just started using QT the day before yesterday and am having a little trouble figuring out how to make a beep noise when my QIntValidator returns false.

I'm using a QLineEdit and a QIntValidator with a range 0-5.

When a user enters an "A" or a "6" (for example), I want my program to qApp->beep

Any advice on doing this?

e8johan
9th September 2010, 08:05
Hi,

First of all - congratulations on starting to use Qt. I hope that you will enjoy it.

In order to make a validator that beeps, you must sub-class the QIntValidator. Then re-implement the validate function. In that function, simply call QIntValidator::validate and return the resulting value. However, you must also monitor that value (before returning it). If it is QValidator::Invalid, then call qApp->beep();

dcsm0001
13th September 2010, 19:53
How is the best way to reimplement the validate function?