如果字符串都是你说的那种形式的话,你可以先找到第一个‘&’的位置,然后用left函数取出来就行了。
int QString::find ( const QString & str, int index=0, bool cs=TRUE ) const
Finds the first occurrence of the string str, starting at position index. If index is -1, the search starts at the last character; if -2, at the next to last character; etc.
The search is case sensitive if cs is TRUE, or case insensitive if cs is FALSE.
Returns the position of str, or -1 if str could not be found.
QString QString::left ( uint len ) const
Returns a substring that contains the len leftmost characters of the string.
The whole string is returned if len exceeds the length of the string.
Example:
QString s = "Pineapple";
QString t = s.left( 4 ); // t == "Pine"