我要编一个读取图象的软件,这是打开文件的功能,也不知道对不对,但是编译通过后老说是段错误,我也没办法知道行不行了,以下是程序对代码,还请各位高手帮忙看一下,感觉qt好难哦,以前从来没有用过C++呀!!
#include<qapplication.h>
#include<qwidget.h>
#include<qfiledialog.h>
#include<qstring.h>
#include<qpushbutton.h>
#include<qlabel.h>
#include<qfont.h>
class OpenFile:public QWidget
{
public:
OpenFile();
private slots:
void open();
private:
QPushButton *b1;
QFileDialog *fdialog;
QString file;
};
OpenFile::OpenFile()
{
setGeometry(500,500,400,300);
b1=new QPushButton("open",this);
b1->setGeometry(20,20,50,30);
b1->setFont(QFont("Times",15,QFont::Bold));
connect(b1,SIGNAL(clicked()),fdialog,SLOT(open()));
}
void OpenFile::open()
{
file=fdialog->getOpenFileName("/","*.bmp");
}
int main(int argc,char **argv)
{
QApplication a(argc,argv);
OpenFile file;
a.setMainWidget(&file);
file.show();
a.exec();
}
[ 此贴被XChinux在2006-05-26 21:07重新编辑 ]