What about reading QFile documentation and your compiler error messages?
Here´s some more or less pseudo code for your open() slot:
void MainWindow::open()
{
QFile openFile
(fname
);
// you may check for fname.isEmpty before openFile.
open(QIODevice::ReadOnly);
// you should do some error checking here! txt
->setPlainText
(QString(content
));
}
void MainWindow::open()
{
QString fname = QFileDialog::getOpenFileName(this, tr("Put your dialog caption here"));
QFile openFile(fname); // you may check for fname.isEmpty before
openFile.open(QIODevice::ReadOnly); // you should do some error checking here!
QByteArray content = openFile.readAll();
txt->setPlainText(QString(content));
}
To copy to clipboard, switch view to plain text mode
If you don't find the methods you're looking for in the documentation of a class, you may also look into the documentation of its parent class. In the code snippet above, readAll() e.g. is documented in class QIODevice, the parent class of QFile.
Bookmarks