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
    Jul 2012
    Location
    Hyderabad
    Posts
    82
    Thanks
    5
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Smile Display only numbers at Last

    Dear Forums,


    I have small doubt in QT..... 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.............I need a validation for it.........Can anyone make it out for me...........Any solution would be appreciable....


    Regards,

    Venugopal.T

  2. #2
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Display only numbers at Last

    Quote Originally Posted by StarRocks View Post
    Dear Forums,


    I have small doubt in QT..... 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.............I need a validation for it.........Can anyone make it out for me...........Any solution would be appreciable....


    Regards,

    Venugopal.T
    I am sorry if it sounds condescending, but you need to understand how this forum works. You have been opening several new topics recently, in which you always ask someone to solve a problem for you, without showing that you actually tried anything on your own. Guess what: the people who help each other here do so for free, in their free time. They will only help you solve your problem, not do it for you. If you are looking for someone to do your work for you, just hire some seasoned Qt developer.

    I suggest you try harder, explain what you have tried; I am confident that someone will then help you.

  3. The following user says thank you to yeye_olive for this useful post:

    d_stranz (7th August 2012)

  4. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Display only numbers at Last

    I have small doubt in QT..... 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.............I need a validation for it.........Can anyone make it out for me...........Any solution would be appreciable....
    You don't explain anything about how or where you want to do this validation. So, if you are trying to validate input into a QLineEdit widget, then I suggest you read about QValidator, QRegExp, and QRegExpValidator. Those classes will allow you to write a validator for the problem you have described.

    And like yeye_olive says, don't simply reply with "OK, give me example code for that". Try it on your own, and if you still can't solve it, post your code and ask what you are doing wrong.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  5. #4
    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

    Hi Guys,

    Thanks for your feedback.........Listen i have posted few queries which i solved by my own noone gave any solutions.......First have a look at my queries im posting queries which i tried a lot and only then im posting to my knowledge that queries are not that easy to solve i guess.........Im not jus posting without trying sorry if i hurt u guys.........

    Regards,

  6. #5
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Display only numbers at Last

    I have small doubt in QT..... 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.............I need a validation for it.........Can anyone make it out for me...........Any solution would be appreciable....
    @StarRocks: Look at what you said here. You did not say anything at all about having tried something. You didn't post any code and ask "Why doesn't this work"? You just said "Here's my problem. Tell me the answer".

    So when you post something like that, what are we supposed to think? Next time, tell us what you've tried and what didn't work so we can at least tell that you aren't just begging for free answers. You will be much more likely to get some help instead of abuse in that case.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  7. #6
    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 d_stranz,

    Its not like im begging for answers and all..............Please understand that first and i have written a code in Javascript and its working for me but i cant implement the same for C++ right....
    As im new to Qt so i want to know how to use that coz its only validation prob ...........For ur reference the below is the code...






    function ValidateVehicleNumber(strVarInstance) {
    var strResult = "";
    var cnt = 0;
    var count1 = 0;
    if (strVarInstance[1] == '') {
    cnt++;
    strResult += "";
    }
    else {
    var VehicleNo = strVarInstance[1];

    if (VehicleNo.length < 4) {
    cnt++;

    strResult += "Vehicle Number contains Atleast four digits \n ";
    }
    else {
    var index = VehicleNo.length - 4
    var count = 0;
    for (i = index; i < VehicleNo.length; i++)
    {
    var c = VehicleNo.charAt(i);

    if (isNaN(c) || c == " " )
    {
    count++;
    }
    if (c == 0) {
    count1++;
    }
    }
    if (count != 0)
    {
    cnt++;

    strResult += "Last four character of Vehicle Number digits only \n ";
    }
    if (count1 == 4) {
    cnt++;

    strResult += "Vehicle Number should not be zeros \n ";

    }
    }
    }
    return strResult;
    }


    Regards

  8. #7
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Display only numbers at Last

    In order to port this code as-is to Qt you need to do the following (in this order):
    1. learn C++;
    2. learn some Qt basics;
    3. have a look at the documentation for the QString and QChar classes, that you will use to represent strings and characters respectively. All the operations you need are there.

    However you can probably replace all this code with a simple regular expression. Once you have done steps 1 and 2 above, you can have a look at QRegExp, which d_stranz mentioned above. The documentation of the class explains the syntax of regular expressions and gives some examples that among other things show how to match digits in a string.

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

    Smile Display only numbers at Last



    Dear Forums,


    Thanks for the reply .......Will go through the things that you asked me to if any doubts will contact you..........


    Regards,

  10. #9
    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 Forums,

    As i have posted previously too i have google searched validations for everything i have got most of them but except the one im searching for i.e having numbers at the last i have tried but achieved only in having something like this as "ap12" but i have to get only numbers after that....Hope you got me......example is IN12AP1212.........Thanks in Advance.......Any solution would be appreciable.....


    Regards,

  11. #10
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Display only numbers at Last

    Have you tried to check the strings with a regular expression? See QRegularExpression.

  12. #11
    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 Lykurg,

    Thanks for the reply....I have gone through the QRegularExpression but dint find any solution through that so posted in the forums again......Any solution would be appreciable.......

    Regards,

Similar Threads

  1. Replies: 2
    Last Post: 26th January 2012, 16:31
  2. How to display the numbers in a QList<QString> ?
    By harish in forum Qt Programming
    Replies: 4
    Last Post: 3rd January 2012, 05:26
  3. Replies: 1
    Last Post: 18th June 2011, 19:28
  4. Replies: 3
    Last Post: 17th April 2010, 22:35
  5. How to use QLCDnumber to display negative numbers?
    By grissiom in forum Qt Programming
    Replies: 1
    Last Post: 19th March 2010, 07: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.