之前有同学分享了qt图像的程序 现在我想做个小改进,按个按钮,在u盘新建一个文件,并写入一些数据
以下是我的源代码
hello程序代码是 eddy提供的
#include "hello.h"
#include <qlabel.h>
#include <qpushbutton.h>
//以下是我为文件操作增加的头文件
#include <qfile.h> //里面包含所需的QFile类
MyHelloForm::MyHelloForm( QWidget* parent, const char* name, WFlags fl)
:HelloBaseForm(parent, name, fl)
{
eddy = new QPixmap("/opt/Qtopia/pics/eddy.jpg");
connect(helloPushButton,SIGNAL(clicked()),this,SLOT(sayHello()));
connect(eddyPushButton,SIGNAL(clicked()),this,SLOT(showMe()));
}
MyHelloForm::~MyHelloForm()
{
}
void MyHelloForm::sayHello()
{
girlPixmapLabel->clear();
girlPixmapLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken );
girlPixmapLabel->setText( "Hello\n\nI am Pretty Girl" );
girlPixmapLabel->setAlignment( AlignCenter );
}
void MyHelloForm::showMe()
{
girlPixmapLabel->clear();
girlPixmapLabel->setPixmap(*eddy);
//以下是我增加的部分
QFile file(“/udisk/kobe10.txt”);
file.open(IO_WriteOnly);//在此模式在打开,会创建不存在的文件,同时不进行任何操作
file.close();
}
程序执行后,在U盘里没有我所创建的文件。。
求助