Hi, I would like the following code to open any text file and display it in a QTextEdit box. This eventually works if I give the file a file name but i want this to open any text file. This is not working and cant figure out why, please help, thx.


void MainWindow:penfiledlg()
{
QFileDialog *filedlg;
filedlg->getOpenFileName(this);

QString fname;
QFile file(fname);
//QFile file("test.txt");

file.open(QFile::ReadOnly | QFile::Text);

QTextStream ReadFile(&file);
ui->textEdit->setText(ReadFile.readAll());
}