PDA

View Full Version : Problem in opening a file



Abc
7th July 2008, 14:12
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:

void MainWindow :: open() {
QString fileName = QFileDialog::getOpenFileName(this,tr("Open File"),"C:\\","C Files (*.c *.h)");
QFile file(fileName);

QFileInfo fi(fileName);
QString fname = fi.fileName();

QRegExp rx("^[a-zA-Z0-9]+[a-zA-Z0- -_-9_]*\\.[cC]$");
if(!rx.exactMatch(fname)) {
QMessageBox::warning(this, tr("CiMPLE - %1").arg(fname),
tr("Cannot Open File! File Name should not contain any characters like -,/\%^&@#"));
return;
}
if (!fileName.isEmpty()) {
CodeTab *newtab = new CodeTab(tabs,fileName);
highlighter = new Highlighter((newtab->getTextEdit())->document());
tabs->AddTab(newtab,tr("%1").arg(fileName));
tabs->setCurrentWidget(newtab);
tabs->setTabNameSaved(true);
statusBar()->showMessage(tr("File loaded"), 2000);
}
}

Please let me know what is the error involved.

wysota
7th July 2008, 14:42
Please provide the backtrace from the debugger.

Abc
12th August 2008, 12:40
Thanks but this seems to have been a problem at my end. Working fine now... :)