Results 1 to 3 of 3

Thread: Making qApp->beep from QIntValidator being false

  1. #1
    Join Date
    Sep 2010
    Posts
    7
    Qt products
    Qt4
    Thanks
    1

    Question Making qApp->beep from QIntValidator being false

    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?

  2. #2
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    3
    Thanked 39 Times in 39 Posts

    Default Re: Making qApp->beep from QIntValidator being false

    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();

  3. #3
    Join Date
    Sep 2010
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Making qApp->beep from QIntValidator being false

    How is the best way to reimplement the validate function?

Similar Threads

  1. Beep Sound under linux
    By chethana in forum Qt Programming
    Replies: 1
    Last Post: 7th June 2009, 09:55
  2. QLineEdit + QIntValidator
    By fruzzo in forum Qt Programming
    Replies: 1
    Last Post: 24th April 2008, 15:14
  3. QIntValidator input
    By chaos_theory in forum Qt Programming
    Replies: 4
    Last Post: 19th August 2007, 11:28
  4. QIntValidator
    By ChasW in forum Qt Programming
    Replies: 2
    Last Post: 12th February 2007, 21:36
  5. generating beep sound in Qt under linux platform
    By babusunlux in forum Qt Programming
    Replies: 10
    Last Post: 7th July 2006, 07:38

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.