[Qt-interest] Qt Complex Data structure (user defined classes with QMap)

yogesh upreti yogesh.upreti at gmail.com
Mon Apr 4 09:36:23 CEST 2011


Hello All,

I am trying to make some complex data structure in Qt. My code looks like
this (using Qt Creator) :

main.cpp:

#include <QtGui/QApplication>

#include "mainwindow.h"

 int main(int argc, char *argv[])

{

    QApplication a(argc, argv);

    MainWindow w;

    w.show();

     return a.exec();

}


mainwindow.h:

#ifndef MAINWINDOW_H

#define MAINWINDOW_H

#include <QMainWindow>

#include <QtGui>

namespace Ui {

    class MainWindow;

}

class SettingsClass {

public:

    SettingsClass();

    QMap<QString, QList<int> > warning;

};

class MainWindow : public QMainWindow

{

    Q_OBJECT

public:

    explicit MainWindow(QWidget *parent = 0);

    SettingsClass *set;

    ~MainWindow();

private:

    Ui::MainWindow *ui;

};

#endif // MAINWINDOW_H


mainwindow.cpp:

#include "mainwindow.h"

#include "ui_mainwindow.h"

#include <QtGui>

 MainWindow::MainWindow(QWidget *parent) :

    QMainWindow(parent),

    ui(new Ui::MainWindow)

{

    ui->setupUi(this);

    QList<int> list = QList<int>();

    list.append(1);

    list.append(2);

    list.append(3);

    list.append(4);

    list.append(5);

    this->set->warning["yogesh"] = list;

     QMapIterator<QString, QList<int> > itr(this->set->warning);

    while(itr.hasNext()){

        itr.next();

        QList<int> temp = itr.value();

        for(int i=0; i<temp.size();i++){

            ui->textEdit->insertPlainText(QString(">> %1: %2 ->
%3\n").arg(itr.key()).arg(i).arg(temp.at(i)));

        }

    }

}

 MainWindow::~MainWindow()

{

    delete ui;

}



My programme compiles properly but its not running and exit with code
-1073741819
anyone knows what could be the problem with the user defined class??

Thanks
Yogesh Upreti
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110404/d5a7b62c/attachment.html 


More information about the Qt-interest-old mailing list