Hi all,
Am encountering a strange debug error when executing some code. No errors or warnings on compilation, but on execution I am presented with an error that says
It seems to be an issue with the opening of a filedialog to allow a user to select a file to be opened. It lets you wither abort, retry or ignore. Choosing ignore the program runs fine.ASSERT: "!parent ||parent->testAttribute(Qt::WA_State_Created)" in file dialogs\qfiledailog_win.cpp line 293"
Any help would be appreciated. Now here's the troublesome code (simplified down into a dumb program)
// messing.cpp file
#include "messing.h"
#include <QtGui>
messing::messing(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
open();
}
messing::~messing()
{
}
void messing::open()
{
QString fileName =
QFileDialog::getOpenFileName(this, tr("Open Xml File"),
QDir::currentPath(),
tr("Xml Files (*.xbel *.xml)"));
if (fileName.isEmpty())
return;
QFile file(fileName);
if (!file.open(QFile::ReadOnly | QFile::Text)) {
QMessageBox::warning(this, tr("Program"),
tr("Cannot read file %1:\n%2.")
.arg(fileName)
.arg(file.errorString()));
return;
}
}
// messing.h
#ifndef MESSING_H
#define MESSING_H
#include <QtGui/QMainWindow>
#include "ui_messing.h"
class messing : public QMainWindow
{
Q_OBJECT
public:
messing(QWidget *parent = 0, Qt::WFlags flags = 0);
~messing();
void open();
private:
Ui::messingClass ui;
};
#endif // MESSING_H
// main.cpp
#include <QtGui/QApplication>
#include "messing.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
messing w;
w.show();
return a.exec();
}


Reply With Quote
Bookmarks