Hmm... did it even compile? There is no such thing as toByteArray() for QString

Should be:
Qt Code:
  1. print name.toAscii().constData()
To copy to clipboard, switch view to plain text mode 
And don't surround name with str(), it will again try to do the conversion on QString which will fail.