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)");
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);
}
}
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);
}
}
To copy to clipboard, switch view to plain text mode
Please let me know what is the error involved.
Bookmarks