how to convert Qstring to Long?
Use the toLong function.
For example,
QString str = "FF";
bool ok;
long hex = str.toLong(&ok, 16); // hex == 255, ok == true
long dec = str.toLong(&ok, 10); // dec == 0, ok == false
From the QT Docs:
long QString::toLong ( bool * ok = 0, int base = 10 ) const
Returns the string converted to a long using base base, which is 10 by default and must be between 2 and 36 or 0. If base is 0, the base is determined automatically using the following rules: If the string begins with "0x", it is assumed to be hexadecimal; If it begins with "0", it is assumed to be octal; Otherwise it is assumed to be decimal. Returns 0 if the conversion fails.
If ok is not 0: if a conversion error occurs, *ok is set to FALSE; otherwise *ok is set to TRUE.
Leading and trailing whitespace is ignored by this function.