Results 1 to 5 of 5

Thread: isDigit() isdigit()

  1. #1
    Join Date
    Dec 2007
    Location
    Groningen Netherlands
    Posts
    182
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default isDigit() isdigit()

    qt 4.3.4 on linux

    When I try to use isDigit() I get error ‘isDigit’ was not declared in this scope. Same goes for other functions from QChar like isNumber() (I did not test them all).

    When i try isdigit() I get error: cannot convert ‘QCharRef’ to ‘int’ for argument ‘1’ to ‘int isdigit(int)’

    But there is no entry in qassistent for isdigit().

    I now use:
    #define isDigit(c) ((c) >= '0' && (c) <= '9')

    but I'm curious as to what others say.
    Last edited by JeanC; 7th June 2008 at 14:44.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: isDigit() isdigit()

    How did you exactly tried to use QChar::isDigit()?

  3. #3
    Join Date
    Dec 2007
    Location
    Groningen Netherlands
    Posts
    182
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: isDigit() isdigit()

    Hi jacek,

    Qt Code:
    1. #include <QChar>
    2.  
    3. somefunction()
    4. {
    5. ...
    6. QString name = songsmodel->record(songrow).value(2).toString();
    7. int n = name.length();
    8. while (!isDigit(name[n]) && name[n] != '-' && n > 0)
    9. n--;
    10. ..
    11. }
    To copy to clipboard, switch view to plain text mode 
    Quote Originally Posted by jacek View Post
    How did you exactly tried to use QChar::isDigit()?

  4. #4
    Join Date
    Sep 2007
    Location
    Rome, GA
    Posts
    199
    Thanks
    14
    Thanked 41 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: isDigit() isdigit()

    length() is not zero-based, like an array index. Change name[n] to name[n - 1] and it should work.

    EDIT: Oh, I see your original problem, you need to have a QChar variable in there in order to call isDigit():

    QChar c = name[n - 1];
    while(!c.isDigit()...
    Last edited by JimDaniel; 7th June 2008 at 18:19.

  5. #5
    Join Date
    Dec 2007
    Location
    Groningen Netherlands
    Posts
    182
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: isDigit() isdigit()

    Duh.

    Makes sense. Thanks.

    Quote Originally Posted by JimDaniel View Post
    EDIT: Oh, I see your original problem, you need to have a QChar variable in there in order to call isDigit():

    QChar c = name[n - 1];
    while(!c.isDigit()...

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.