Logo Search packages:      
Sourcecode: qt4-x11 version File versions  Download package

void MainWindow::loadFile ( const QString fileName ) [private]

[41]

[42] [42] //! [43]

Definition at line 318 of file mainwindow.cpp.

References QIODevice::errorString(), QFile::open(), QTextStream::readAll(), QApplication::restoreOverrideCursor(), setCurrentFile(), QApplication::setOverrideCursor(), QTextEdit::setPlainText(), QStatusBar::showMessage(), QMainWindow::statusBar(), and QMessageBox::warning().

{
    QFile file(fileName);
    if (!file.open(QFile::ReadOnly | QFile::Text)) {
        QMessageBox::warning(this, tr("Application"),
                             tr("Cannot read file %1:\n%2.")
                             .arg(fileName)
                             .arg(file.errorString()));
        return;
    }

    QTextStream in(&file);
    QApplication::setOverrideCursor(Qt::WaitCursor);
    textEdit->setPlainText(in.readAll());
    QApplication::restoreOverrideCursor();

    setCurrentFile(fileName);
    statusBar()->showMessage(tr("File loaded"), 2000);
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index