Results 1 to 3 of 3

Thread: Problem in opening a file

  1. #1
    Join Date
    Jun 2008
    Posts
    22

    Default Problem in opening a file

    I have made an MDI application using Qt.
    Initially I was using Qt 4.3. I changed to Qt 4.4 for the application I have built in Qt.
    But after doing this, every time I try to open a file, my application crashes.

    I have written the function for the same as under:
    Qt Code:
    1. void MainWindow :: open() {
    2. QString fileName = QFileDialog::getOpenFileName(this,tr("Open File"),"C:\\","C Files (*.c *.h)");
    3. QFile file(fileName);
    4.  
    5. QFileInfo fi(fileName);
    6. QString fname = fi.fileName();
    7.  
    8. QRegExp rx("^[a-zA-Z0-9]+[a-zA-Z0- -_-9_]*\\.[cC]$");
    9. if(!rx.exactMatch(fname)) {
    10. QMessageBox::warning(this, tr("CiMPLE - %1").arg(fname),
    11. tr("Cannot Open File! File Name should not contain any characters like -,/\%^&@#"));
    12. return;
    13. }
    14. if (!fileName.isEmpty()) {
    15. CodeTab *newtab = new CodeTab(tabs,fileName);
    16. highlighter = new Highlighter((newtab->getTextEdit())->document());
    17. tabs->AddTab(newtab,tr("%1").arg(fileName));
    18. tabs->setCurrentWidget(newtab);
    19. tabs->setTabNameSaved(true);
    20. statusBar()->showMessage(tr("File loaded"), 2000);
    21. }
    22. }
    To copy to clipboard, switch view to plain text mode 

    Please let me know what is the error involved.
    Last edited by jpn; 7th July 2008 at 15:33. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem in opening a file

    Please provide the backtrace from the debugger.

  3. #3
    Join Date
    Jun 2008
    Posts
    22

    Default Re: Problem in opening a file

    Thanks but this seems to have been a problem at my end. Working fine now...

Similar Threads

  1. How to save file with QFileDialog
    By pnikolov in forum Qt Programming
    Replies: 11
    Last Post: 1st June 2012, 11:23
  2. Draging a non-existing file to the Windows Desktop
    By klaus1111 in forum Qt Programming
    Replies: 13
    Last Post: 20th September 2007, 12:47
  3. Facing problem with tool bar icons
    By jnana in forum Qt Programming
    Replies: 4
    Last Post: 20th April 2006, 09:37
  4. Problem with reading a file
    By Buhmann in forum Qt Programming
    Replies: 11
    Last Post: 17th February 2006, 14:02
  5. QProcess problem with windows batch file
    By bood in forum Qt Programming
    Replies: 11
    Last Post: 6th January 2006, 09:08

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.