Hi
I want to show my array's on a label, so i want to convert my char array to string for a label.
How may i do this?
Hi
I want to show my array's on a label, so i want to convert my char array to string for a label.
How may i do this?
Just use QLabel::setText(const QString &) function with your array as the argument. QString class will make conversion for you.
For instance:
Qt Code:
char array[] = "Some text"; QLabel label; label.setText(array);To copy to clipboard, switch view to plain text mode
anafor2004 (2nd May 2008)
by the way,
why dont u use QString itself instead of the char[] ??
Hello,
jst convert ur array[] to QString..
Qt Code:
char array[] = "Hello World"; str = array; QLabel tempLabel; tempLabel.setText( str );To copy to clipboard, switch view to plain text mode
it is not working,
The last method is incorrect. You cannot just assign a pointer to char array to a pointer to QString. Why don't use the solution I've suggested earlier? There is no need to make things harder. If you need QString not only to set for a label but for other aims too, just instantiate QString with your array as a parameter:
Qt Code:
char array[] = "Some text";To copy to clipboard, switch view to plain text mode
Last edited by mitro; 6th May 2008 at 16:03.
Bookmarks