Problem with QLineEdit and setText
I have a pice of code that looks like this...
Code:
...
str = "hi to everybody";
t1->setText(str);
...
After the execution of "t1->setText(str);" the program breaks with a segmentation fault error.
Probably I am doing something very badly.
Thank you for your help
BTW: the code compiles without any error :)
Re: Problem with QLineEdit and setText
The code you posted should work ok.
Are you sure it crashes on t1->setText(str) and not later?
Could you show a bit more of the code before and after the lines you posted?
Re: Problem with QLineEdit and setText
The exact code is this (sorry, names are in spanish):
Code:
void WInfo::cargar_info_personal()
{
int sexo, pais;
int dia, mes, ano;
//Get the information
datos_leer_info_personal(estDatos, &nick, &nombre, &apellido, &ciudad,
&sexo, &pais, &dia, &mes, &ano);
QDate fecha
(ano, mes, dia
);
t1->setText(nick);
t2->setText(nombre);
t3->setText(apellido);
c4->setCurrentIndex(sexo);
c5->setCurrentIndex(0);
t6->setText(ciudad);
f7->setDate(fecha);
}
I have been debugging it with gdb, and it breaks in "t1->setText(nick);" if I comment it it breaks in "t2->setText(nombre);", byt if I write "t1->setText("string");" it works without problems.
t* are declared in the header of the class and initilialized when the class is created.
Re: Problem with QLineEdit and setText
I think you have to take a look at "datos_leer_info_personal".
Test the values of "nick" etc. ...
Re: Problem with QLineEdit and setText
I checked it already, I tried to give values to the QStrings after calling datos_leer_info_personal();
and all is the same... :(
Re: Problem with QLineEdit and setText
Are you sure that t1, t2 and t3 are initialized before cargar_info_personal() is invoked?
Re: Problem with QLineEdit and setText
Try cleaning the project an rebuild.
See if it still crashes.
If it does:
comment out datos_leer_info_personal() and try.
Then please post the code inside datos_leer_info_personal().
Re: Problem with QLineEdit and setText
I would try any other function that requires a QString as input and see if it breaks the same way. My guess is it has something to do with how your QString is initialized.
Re: Problem with QLineEdit and setText
Thanks to everybody. I just reinstaled QT 4 libraries and it works now. This magic of computers :(