[Qt-interest] Qt Complex Data structure (user defined classes with QMap)
Jaco Naude
naude.jaco at gmail.com
Mon Apr 4 10:43:15 CEST 2011
Run it in debug mode and see where it crashes...
On Mon, Apr 4, 2011 at 7:36 AM, yogesh upreti <yogesh.upreti at gmail.com>wrote:
> 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
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110404/81c1173e/attachment.html
More information about the Qt-interest-old
mailing list