Alright, found 1st part of answer:
function qa_userids_to_handles (in qa-app-users.php)
EDIT:
and this is how you do it:
// get handles in array usernames ($userids MUST be an array)
$usernames = qa_userids_to_handles($userids);
// and then I iterate over an array like that:
foreach ($scores as $userId => $val) {
$currentUser = $usernames[$userId];
$user = qa_db_select_with_pending( qa_db_user_account_selectspec($currentUser, false) );
$bestusers .= "<li>" . qa_get_user_avatar_html($user['flags'], $user['email'], $user['handle'], $user['avatarblobid'], $user['avatarwidth'], $user['avatarheight'], qa_opt('avatar_users_size'), true) . " "
. qa_get_one_user_html($usernames[$userId], false).' ('.$val.')</li>';
}
---
Edit 2012-11-01:
This is the code I am using now in my plugins to get the username by passing the userid!
// get user details (display avatar and name)
$username = qa_db_read_all_assoc(qa_db_query_sub('SELECT handle FROM ^users WHERE userid = #',$row['userid']), 'handle');
$user = qa_db_select_with_pending( qa_db_user_account_selectspec($username, false) );
$revLink = isset($row['title']) ? $row['title'] : "Answer was edited";
$htmloutput .= '<tr> <td>'.date("Y-m-d H:m", strtotime($row['updated'])).'</td>
<td><a href="'.$activity_url.'">'.$revLink.'</a> <br />'.$display_post_url.'</td>
<td>'. qa_get_user_avatar_html($user['flags'], $user['email'], $user['handle'], $user['avatarblobid'], $user['avatarwidth'], $user['avatarheight'], qa_opt('avatar_users_size'), false) . " " . qa_get_one_user_html($user['handle'], false).'</td></tr>';
If you only want to query 1 username use:
$username = qa_db_read_one_assoc(qa_db_query_sub('SELECT handle FROM ^users WHERE userid = #',$row['userid']), 'handle');