ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am new to Linux and QT, recently installed Red-hat 9 and am having problems with QString. Ive been through the QT Designer - Quick start - tutorials everything compiles and working fine but can only find examples of making QString variables with a string set when declared that doesn't change.
I wanted to read a string in from a file then displays it in a QLineedit, then turn the string round, so it is back to front and displays it in another line QLineedit.
I have got a simple c program to do this but displays the string at the command line instead, using ( char ) arrays and ( FILE ).
I hadn’t used QT before and tried to use the equivalent of:
char string[50] = "a string";
myLineedit->setText(string);
and I got an error saying it needs a ( const QString* ) or something like that, so I tried:
QString string[50] = "a string";
I got more errors, but it let me do:
QString string = "a string";
I compiled and it worked, but once I’d done that. I couldn’t find a way to swap the string round so it was back to front i.e. "gnirts a", except by a separate ( char ), is there a way?
I tried:
char temp[50] = "my string";
QString string = temp;
But again I got errors, so I looked on the Internet an found I could use the
mylineedit->setText(QString("%1").arg( temp ) ):
That worked as long as temp wasn’t an array.
Is there any way you can use QString like a ( char ) array?
Or sending an array to setText?
Or any other way of changing a string round char by char you could think of? All suggestions and help are welcome.
ill i want to do now is convert from QString back to char[], So i can put back in that array whatever is in a QLineedit, i found the .ascii() and .latin1() functions but they dont seem to work on char arrays through:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.