Results 1 to 20 of 46

Thread: Display only numbers at Last

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Display only numbers at Last

    Show us what you have tried to do with those classes rather than just telling us that you have "used most of the syntax in my application" or that you "have even read the docs". We cannot fix or guide based on what we cannot see.

    This is how you show us. Copy the following two lines into a reply:
    [code]
    [/code]

    Then, between the two tags, paste your best attempt at coding the function to validate the input and press Submit Reply.

    The solution can be had using only the classes pointed out in this thread. I estimate an equivalent of your script routine consists of less than twenty lines. That depends a little on exactly what "strVarInstance" represents because the script code is, well, odd.

  2. #2
    Join Date
    Jul 2012
    Location
    Hyderabad
    Posts
    82
    Thanks
    5
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Smile Re: Display only numbers at Last

    Dear Chris,


    Thanks for the reply......Please find the below code about how i used one of the syntax for my application.........

    Qt Code:
    1. QRegExp rxlen("(\\d+)(?:\\s*)([0-9]|[A-Z])");
    2. int pos = rxlen.indexIn("Length: 1212AP");
    3.  
    4. if (pos > -1) {
    5. QString value = rxlen.cap(1); // "189"
    6. QString unit = rxlen.cap(2); // "cm"
    7.  
    8. QString uts = rxlen.cap(3);
    9.  
    10. qDebug()<<value<<"The Value is";
    11. qDebug()<<unit<<"The Unit is";
    12. qDebug()<<uts<<"The Uts is";
    To copy to clipboard, switch view to plain text mode 


    Thanks in Advance.....Any solution would be appreciable........



    Regards,

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Display only numbers at Last

    Your expression reads: one or more digits followed by a 0 or more white spaces followed by a digit or capital letter. There is no cap(3) here. Did you really think this expression would match a string such as "INAP1212"?

    Quote Originally Posted by StarRocks
    Guys i have Vehicle number as INAP1212 now what i need is each and everytime the last four should always be digits and should not be 0000
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Jul 2012
    Location
    Hyderabad
    Posts
    82
    Thanks
    5
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Smile Re: Display only numbers at Last

    Dear Wysota,


    Thanks for the reply......Actually in my code i have commented that line but forgot to do the same in the coding that i have posted........Hope you understood the situation that i have posted.........Any solution would be appreciable.......Thanks in Advance...Actually i am not exactly knowing how to have syntax in that format...


    Regards,

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Display only numbers at Last

    So what expression did you code if it wasn't the one you posted?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Display only numbers at Last

    Concentrate on getting a regular expression that matches 4 or more digits. Once you have that extend it by forcing the match to only occur at the end of the string and you will be most of the way there. You may find an online regular expression tester a useful tool to help learn in conjunction with the Qt docs.

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Display only numbers at Last

    This one is also ok: http://www.regexper.com/
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #8
    Join Date
    Jul 2012
    Location
    Hyderabad
    Posts
    82
    Thanks
    5
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Smile Re: Display only numbers at Last

    Dear Wysota,


    Thanks for the reply.......Actually i have done the validation something like this.........Just look the code phrased below

    Qt Code:
    1. QRegExp rx("([A-Za-z][A-Za-z][0-9][0-9][A-Za-z][A-Za-z][0-9]+)/([A-Za-z]+)");
    2. QValidator *validator = new QRegExpValidator(rx, this);
    3. ui->lineEditVehicleNumber->setValidator(validator);
    4. qDebug()<<"The Vehicle number is"<<rx;
    To copy to clipboard, switch view to plain text mode 



    But actually i am getting the format which i wanted to have numbers at last but im not satisfied with the coding that i have done......Can anyone remodify it......Thanks in Advance......Any solution would be appreciable.


    Regards,

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Display only numbers at Last

    The expression says: "Two letter upper or lower case followed by two digits followed by two letters and at least one digit then the '/' character and any number of lower or upper case letters". Is that what you wanted?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #10
    Join Date
    Jul 2012
    Location
    Hyderabad
    Posts
    82
    Thanks
    5
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Display only numbers at Last

    Dear Wysota,


    Thanks for the reply......Actually i have written the code in the right way what format i need is "AP12QW1234" the last four what ever we are giving should be numbers.......Thanks in advance.........Any solution would be appreciable.......


    Regards,

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Display only numbers at Last

    The expression you posted will not match this string. It doesn't have a '/' character anywhere nor does it end with letters. Did you come up with this expression on your own?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  12. #12
    Join Date
    Jul 2012
    Location
    Hyderabad
    Posts
    82
    Thanks
    5
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Display only numbers at Last

    Dear Wysota,


    Thanks for the reply......yep i have done the validation by myself......Thanks in advance.........Any solution would be appreciable.......


    Regards,

Similar Threads

  1. Replies: 2
    Last Post: 26th January 2012, 15:31
  2. How to display the numbers in a QList<QString> ?
    By harish in forum Qt Programming
    Replies: 4
    Last Post: 3rd January 2012, 04:26
  3. Replies: 1
    Last Post: 18th June 2011, 18:28
  4. Replies: 3
    Last Post: 17th April 2010, 21:35
  5. How to use QLCDnumber to display negative numbers?
    By grissiom in forum Qt Programming
    Replies: 1
    Last Post: 19th March 2010, 06:23

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.