我使用QtSDK创建了一个UI,现在我想要将用户在UI中输入的数据转换为静态文件。我怎样才能做到这一点? 例如,我想:在Qt4 UI中将用户输入的数据写入文件
ofstream myfile ("C:\\testcase.txt");
if (myfile.is_open()) {
myfile << "ui->lineEdit->text()";
} else {
cout << "Unable to open file";
}
,它是印刷双引号内的线,因为它是在该文件中,而不是打印在lineEdit输入的文本的,如果我写
myfile << ui -> lineEdit -> text();
无双引号,代码显示以下错误。
mainwindow.cpp:198: error: no match for 'operator<<' in 'myfile << QLineEdit::text() const()'
应该怎么做?
要回答你的问题,你需要看到更多你的代码和/或确切的消息。 –
'ofstream myfile(“C:\\ testcase.txt”); (myfile.is_open()) {myfile << ui-> lineEdit-> text();} else {cout <<“Unable to open file”;}'是Iam打开文件进行写入的代码部分,错误显示为'C:\ QtSDK \ QtCreator \ bin \ test-build-desktop-Qt_4_7_4_for_Desktop _-_ MinGW_4_4__Qt_SDK__Debug \ .. \ test \ mainwindow.cpp:198:错误:'myfile << QLineEdit'中没有匹配'operator <<' :: text()const()'' – user976369