Results 1 to 3 of 3

Thread: Please explain this code to me

  1. #1
    Join Date
    Mar 2015
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Question Please explain this code to me

    Hi,

    I'm using Qt 5.3.0 and this code is a solution to one of our assignment questions that we had to do. Please see my comments in the following extraction of code. Not sure if I understand it correctly:

    else{
    uName += lName;
    int chars = 4 - lName.size();
    if(fName.size() >= (chars +1)){ //what is the purpose of the +1?
    fName.resize(chars +1);
    uName += fName;
    }
    else{
    uName +=fName;
    uName += QString(5-uName.size(), '0'); //I suppose the '0' is to add zeros at the end of the string?
    Attached Files Attached Files

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Please explain this code to me

    one of our assignment questions that we had to do
    ok, so what was the question ?

  3. #3
    Join Date
    Mar 2015
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Please explain this code to me

    Thanks, attached is the questionQUESTION 1.jpg

Similar Threads

  1. Replies: 1
    Last Post: 6th August 2014, 10:25
  2. Replies: 11
    Last Post: 17th March 2011, 20:17
  3. Can't explain these errors
    By Petr_Kropotkin in forum Newbie
    Replies: 4
    Last Post: 23rd January 2010, 19:06
  4. Explain Qt library sizes, please
    By bnilsson in forum Installation and Deployment
    Replies: 15
    Last Post: 25th July 2009, 10:01
  5. could somebody please explain const to me?
    By mikro in forum General Programming
    Replies: 4
    Last Post: 29th September 2006, 14:34

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.