First of all, access your Gmail account in a web browser, then go to Settings (in the upper-right corner of the page), click on Forwarding and POP/IMAP link in the new page, and make sure to enable POP (either for all mail or for mail that arrives from now on).
Now, run KMail. The first time KMail starts it will prompt you with a welcome window, asking you to create a new identity:
Click on Next and at the following step make sure to select POP3 in the list:
At the following step enter your account information (you can leave the Organization field empty) and press Next:
In the window that appears now, enter your login name (that is your entire Gmail address) and the password:
Click next, and in the following window fill in the fields as shown in the image below (for Incoming server you should use pop.gmail.com and for Outgoing server use smtp.gmail.com):
Now click Finish. You should be prompted by KWallet to store your Gmail username and password, but you can choose not to store you password in KWallet and enter it every time you want to check your email.
Now KMail will start up and you will be able to press on Check Mail in order to have access to your Google email.
If the welcome message doesn't appear when starting KMail (if you already created an account before), then go to Settings -> Configure KMail, then go to the Accounts tab and add a new account for both incoming and receiving mail, using the servers and settings show above.
Also make sure to enable SSL encryption in the Security tab: You can also press on Check What the Server Supports to retrieve the settings automatically:
That's it! KMail should be now correctly set up for accessing your Gmail account.