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

void AddressBook::saveToFile (  )  [slot]

[save and load functions declaration]

[saveToFile() function part1]

[saveToFile() function part1] [saveToFile() function part2]

[saveToFile() function part2] [saveToFile() function part3]

Definition at line 331 of file addressbook.cpp.

References contacts, QIODevice::errorString(), QFileDialog::getSaveFileName(), QMessageBox::information(), QString::isEmpty(), QFile::open(), and QDataStream::setVersion().

    QString fileName = QFileDialog::getSaveFileName(this,
        tr("Save Address Book"), "",
        tr("Address Book (*.abk);;All Files (*)"));

//! [saveToFile() function part1]
//! [saveToFile() function part2]
    if (fileName.isEmpty())
    else {
        QFile file(fileName);
        if (!file.open(QIODevice::WriteOnly)) {
            QMessageBox::information(this, tr("Unable to open file"),

//! [saveToFile() function part2]        
//! [saveToFile() function part3]
        QDataStream out(&file);
        out << contacts;

Generated by  Doxygen 1.6.0   Back to index