Results 1 to 2 of 2

Thread: Debug issue (Qdialog)

  1. #1
    Join Date
    Sep 2008
    Posts
    24
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    8

    Default Debug issue (Qdialog)

    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

    ASSERT: "!parent ||parent->testAttribute(Qt::WA_State_Created)" in file dialogs\qfiledailog_win.cpp line 293"
    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.

    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();
    }

  2. #2
    Join Date
    Sep 2008
    Posts
    24
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    8

    Default Re: Debug issue (Qdialog)

    Hmm seem to have solved it (somewhat). By not putting the open command in the constructor but rather having a pushbutton have the open() action.

Similar Threads

  1. Replies: 1
    Last Post: 28th October 2008, 16:29
  2. Qt::WA_DeleteOnClose while a child QDialog is executed
    By nooky59 in forum Qt Programming
    Replies: 4
    Last Post: 11th July 2008, 12:45
  3. Some very weird compilation warnings
    By MarkoSan in forum Qt Programming
    Replies: 21
    Last Post: 23rd January 2008, 16:48
  4. Replies: 2
    Last Post: 8th November 2007, 20:15
  5. Adding custom defines when on debug build
    By chus in forum Qt Programming
    Replies: 2
    Last Post: 2nd March 2007, 11:38

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
  •  
Qt is a trademark of The Qt Company.