Results 1 to 4 of 4

Thread: User name and password generation

  1. #1
    Join Date
    Jan 2018
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default User name and password generation

    Hi
    I have to build a QT widget using Qt Message box and Qt input dialogue that accepts a full first name and second name, then generates a user name and password. using the below criteria:
    It consists of 5 lower case characters.
    • The user name is created by combining the first 4 characters of the first name with the first
    character of the surname.
    • If the first name does not have 4 characters, more characters are taken from the surname to
    make up the user name.
    • If the total number of characters in the first name and the surname is less than 5 then append
    sufficient number of 0s to create the username.
    An initial password is generated by combining randomly selected 5 characters from the full
    name of the user.
    Note than no spaces are allowed in the username or password.
    User input should be obtained using a QInputDialog. You can expect the full name as a
    single string where each word is separated using a space. For example: Mike William
    Owen. The output (username and password) should be displayed using a QMessageBox.
    You need not do any verification of the user input. You can assume that the user will enter at
    least two words in the QInputDialog. Assume that the first word of the input is the first name
    and the last word in the name is the surname - for example, for the sample input Mike
    William Owen, Mike should be read as the first name and Owen as the surname and the
    generated username should be mikeo.

    I only managed to do the below:
    I would appreciate any help.

    <code>

    #include <QApplication>
    #include <QInputDialog>
    #include <QMessageBox>
    #include <QString>
    #include <QTextStream>

    QTextStream cout(stdout);
    QTextStream cin(stdin);

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    QString userFull, user1, user2;

    userFull = QInputDialog::getText(0,"Please enter your full name: ", "User Name");




    QMessageBox::information(0,"username: ", userFull);

    //user1 = userFull.length();

    //QString userinput = QInputDialog::getText(0,"Please enter your lastname: ", "User Name");
    //getline(cin, user2);

    //if(user1.size() < 3)

    //for(int i = 0; i < user1; i++)
    // getline(cin, user1.size(3));

    // user1 = userName.size(3);

    return a.exec();
    }

    </code>

  2. #2
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    503
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: User name and password generation

    Sounds like homework...
    You'll have to check the docs for QString, especially methods like split() and left().

    Ginsengelf

  3. #3
    Join Date
    Jan 2018
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: User name and password generation

    Hi Ginsengelf
    Thank you for the info.
    Would like to know how do I store individual strings in a QSstring variable, if I enter a complete string such as "My name is". Then I would like to store "My" in a separate string and so with "name" and "is", but I only enter a complete string for input using QStringList.
    regards

  4. #4
    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: User name and password generation

    but I only enter a complete string for input using QStringList.
    And if you looked at the documentation for QStringList you would see that it is simply a QList of QString. And that if you store "My name is" into a QString, there are QString methods to split that into a QStringList containing the individual words.

    Like you were told earlier, we don't do your homework for you. The description in your first post reads exactly like you copied and pasted it it from your homework assignment.
    <=== 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.

Similar Threads

  1. help me create login page with multi-user (admin-user)
    By phovyanz in forum Qt Programming
    Replies: 2
    Last Post: 22nd February 2016, 09:57
  2. Barcode Generation ??
    By sai_3289 in forum Qt Programming
    Replies: 8
    Last Post: 17th December 2013, 08:59
  3. QDialog that asks user for root password
    By Cyrebo in forum Qt Programming
    Replies: 7
    Last Post: 27th April 2013, 07:17
  4. Replies: 2
    Last Post: 27th November 2008, 11:16
  5. Random no. generation using QT3??
    By darpan in forum General Programming
    Replies: 1
    Last Post: 8th August 2006, 13:02

Tags for this Thread

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.