标签:style blog http os ar 文件 2014 div sp
void Widget::on_pushButton_clicked()
{
QString s1 = ui->lineEdit->text();
QString s2 = ui->lineEdit_2->text();
int sum = s1.toInt(0,10) + s2.toInt(0,10);
ui->textEdit->setText(QString::number(sum , 10));
}
void Widget::on_pushButton_clicked()
{
QString filename = QFileDialog::getOpenFileName(0,"打开");
if (filename.isEmpty())
return;
FILE *fp = fopen(filename.toStdString().data(),"r");
if (!fp)
return;
char buf[1024];
QString str;
while (!feof(fp))
{
fgets(buf , sizeof(buf) , fp);
str += buf;
}
ui->textEdit->setText(str);
}
void Widget::on_pushButton_2_clicked()
{
QString filename = QFileDialog::getSaveFileName(0,"保存");
if(filename.isEmpty())
return;
FILE *fp = fopen(filename.toStdString().data(),"w");
if (!fp)
return;
const char *str = ui->textEdit->toPlainText().toStdString().data();
fputs(str,fp);
fclose(fp);
}
标签:style blog http os ar 文件 2014 div sp
原文地址:http://www.cnblogs.com/l6241425/p/3972021.html