PDA

View Full Version : QFileDialog problem



jpoz
28th November 2008, 05:03
hi
i have a problem on QFileDialog,i want to save data from QTableWidget ,here is my function for saving but i am getting error!Please help me on this...


void AddressBook::on_actionSave_triggered()
{

QString fileName = QFileDialog::getSaveFileName(
this );

if (!fileName.isEmpty()) {
tableWidget->writeToFile(fileName);
}
}


error

addressbook.cpp: In member function ‘void AddressBook::on_actionSave_triggered()’:
addressbook.cpp:78: error: ‘class QTableWidget’ has no member named ‘writeToFile’
make[1]: *** [debug/addressbook.o] Error 1

spirit
28th November 2008, 08:16
where is writeToFile located? QTableWidget doesn't have such method.

sadjoker
29th November 2008, 12:02
He probably missed to implement the writeToFile function from AddressWidget example


void AddressWidget::writeToFile(QString fileName)
{
QFile file(fileName);

if (!file.open(QIODevice::WriteOnly)) {
QMessageBox::information(this, tr("Unable to open file"), file.errorString());
return;
}

QList< QPair<QString, QString> > pairs = table->getList();
QDataStream out(&file);
out << pairs;
}