Thanks for your help. I'd be happy to show you my code:
My *.h file
{
..........
public:
void function1();
void function2();
private:
..........
}
class MyWidget : public QWidget
{
..........
public:
void function1();
void function2();
private:
QStringList list2;
..........
}
To copy to clipboard, switch view to plain text mode
There's nothing in the constructor for the QStringList.
My main *.cpp file:
void MyWidget::function1(){
QStringList list;
// declared and filled with data, everything OK here .....................
i =4;
for (int j =0; j <list.size(); j++)
{
list2[j] = list[i];
i +=1;
if (i>=list.size()) i=0;
}
function2();
}
void MyWidget::function2(){
// contains my C code to test if the right thing happened
//nothing is written into the output file
// but it works if I put this code inside function1()
//so I know there are no logic or syntax error
FILE *my;
if ((my=fopen("output.txt","w")) == 0) {exit(1);}
char filename2[70];
for (int k =0; k <list2.size(); k++){
strncpy(filename2, list2[k].toLocal8Bit().constData(), 70);
fprintf(my, "%s\n", filename2);
}
fclose(my);
}
void MyWidget::function1(){
QStringList list; // declared and filled with data, everything OK here
.....................
i =4;
QStringList list2(list);
for (int j =0; j <list.size(); j++)
{
list2[j] = list[i];
i +=1;
if (i>=list.size()) i=0;
}
function2();
}
void MyWidget::function2(){
// contains my C code to test if the right thing happened
//nothing is written into the output file
// but it works if I put this code inside function1()
//so I know there are no logic or syntax error
FILE *my;
if ((my=fopen("output.txt","w")) == 0) {exit(1);}
char filename2[70];
for (int k =0; k <list2.size(); k++){
strncpy(filename2, list2[k].toLocal8Bit().constData(), 70);
fprintf(my, "%s\n", filename2);
}
fclose(my);
}
To copy to clipboard, switch view to plain text mode
Bookmarks