martial_arts_drummer
6th February 2011, 12:13
Ok, I can't figure out why this is not working:
QString temp_vol_id = temp_string;
int first_dot = temp_string.indexOf(".");
int last_dot = temp_string.lastIndexOf(".");
QString temp_name = temp_string.mid((first_dot+1),((last_dot-first_dot)-1))
where temp_vol_id = a valid 82 char qstring
first_dot = 47
last_dot = 61
the debugger states temp_name is <invalid>
I attempted changing qstring.mid second parameter to -1 (it should extract from
first_dot to end of string, but that also returns <invalid>
I am using similar statements in other sections of the code successfully.
Can anyone see anything incorrect in this snippet of code?
thanks
John
Added after 5 minutes:
I should have included the complete function for clarity:
QString Widget::get_Vol_ID(QString temp_string)
{
QString temp_vol_id = temp_string;
int first_dot = temp_vol_id.indexOf(".");
int last_dot = temp_vol_id.lastIndexOf(".");
QString temp_name1 = temp_vol_id.mid((first_dot+1),((last_dot-first_dot)-1));
// QString temp_name = temp_vol_id.mid(first_dot,-1);
// QString temp_name = temp_vol_id.mid((first_dot+1),((last_dot-first_dot)-1));
QString temp_noise = "";
return(temp_name1);
}
you can see the commented out lines that were attempted (without success)
thanks
John
QString temp_vol_id = temp_string;
int first_dot = temp_string.indexOf(".");
int last_dot = temp_string.lastIndexOf(".");
QString temp_name = temp_string.mid((first_dot+1),((last_dot-first_dot)-1))
where temp_vol_id = a valid 82 char qstring
first_dot = 47
last_dot = 61
the debugger states temp_name is <invalid>
I attempted changing qstring.mid second parameter to -1 (it should extract from
first_dot to end of string, but that also returns <invalid>
I am using similar statements in other sections of the code successfully.
Can anyone see anything incorrect in this snippet of code?
thanks
John
Added after 5 minutes:
I should have included the complete function for clarity:
QString Widget::get_Vol_ID(QString temp_string)
{
QString temp_vol_id = temp_string;
int first_dot = temp_vol_id.indexOf(".");
int last_dot = temp_vol_id.lastIndexOf(".");
QString temp_name1 = temp_vol_id.mid((first_dot+1),((last_dot-first_dot)-1));
// QString temp_name = temp_vol_id.mid(first_dot,-1);
// QString temp_name = temp_vol_id.mid((first_dot+1),((last_dot-first_dot)-1));
QString temp_noise = "";
return(temp_name1);
}
you can see the commented out lines that were attempted (without success)
thanks
John