Results 1 to 3 of 3

Thread: QFileDialog problem

  1. #1
    Join Date
    Nov 2008
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QFileDialog problem

    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...

    Qt Code:
    1. void AddressBook::on_actionSave_triggered()
    2. {
    3.  
    4. QString fileName = QFileDialog::getSaveFileName(
    5. this );
    6.  
    7. if (!fileName.isEmpty()) {
    8. tableWidget->writeToFile(fileName);
    9. }
    10. }
    To copy to clipboard, switch view to plain text mode 


    error
    Qt Code:
    1. addressbook.cpp: In member function ‘void AddressBook::on_actionSave_triggered()’:
    2. addressbook.cpp:78: error: ‘class QTableWidget’ has no member named ‘writeToFile’
    3. make[1]: *** [debug/addressbook.o] Error 1
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QFileDialog problem

    where is writeToFile located? QTableWidget doesn't have such method.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Feb 2008
    Posts
    50
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QFileDialog problem

    He probably missed to implement the writeToFile function from AddressWidget example

    Qt Code:
    1. void AddressWidget::writeToFile(QString fileName)
    2. {
    3. QFile file(fileName);
    4.  
    5. if (!file.open(QIODevice::WriteOnly)) {
    6. QMessageBox::information(this, tr("Unable to open file"), file.errorString());
    7. return;
    8. }
    9.  
    10. QList< QPair<QString, QString> > pairs = table->getList();
    11. QDataStream out(&file);
    12. out << pairs;
    13. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Weird problem: multithread QT app kills my linux
    By Ishark in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 10:12
  2. QFileDialog in Qt designer
    By tpf80 in forum Qt Tools
    Replies: 1
    Last Post: 17th May 2007, 01:41
  3. Problem in the QFileDialog
    By joseph in forum Qt Programming
    Replies: 11
    Last Post: 7th December 2006, 10:56
  4. Qfiledialog Problem - (Beginner)
    By kingslee in forum Qt Tools
    Replies: 3
    Last Post: 12th October 2006, 00:00
  5. Replies: 16
    Last Post: 7th March 2006, 16:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.