Segmentation fault

Yayati Ekbote
Hi guys,

I have prepared an application successfully using a QListView class in
x86-qtopia using qt2 designer. My application gets compiled successfully
but gives segmentation fault when i run the application. What must be the
problem?

skip2816
do rebuild all files, linking of object files from non up to date moc's can
cause segmentation fault.

skip

Yayati Ekbote
I prepared a small application for testing using a QListView. I drew
ListView widget on my form which i named ListView and named ny UI file as
myapp_base.ui.

In my header file i wrote-

#ifndef MYAPP_H
#define MYAPP_H

#include "myapp_base.h"

class MyApp : public MyAppBase
{
public:
        MyApp(QWidget *parent=0,const char *name=0, WFlags fl=0);
        ~MyApp();

}

My implementation file is following-

#include "myapp.h"
#include <qlistview.h>

MyApp::MyApp(QWidget *parent, const char *name,WFlags fl):
MyAppBase(parent,name,fl)
{
   QListViewItem *newItem;
   newItem->setText(0,"newItem");
   ListView->insertItem(newItem);     
}

MyApp::~MyApp()
{
}

And my main file is-

#include "myapp.h"
#include <qapplication.h>

int main(int argc, char *argv[])
{
    QApplication app(argc,argv);
    MyApp *obj;
    obj->show();

   return app.exec();
}

My code gets compiled successfully but gives a runtime segmentation fault.
What is the problem??

skip2816
MyApp *obj;
    obj->show();

change to :

    MyApp obj;
    obj.show();

or 

    MyApp *obj = new MyApp();
    obj->show();

Yayati Ekbote
Ok, But then when i wrote main like this-

#include "myapp.h"
#include <qapplication.h>

int main(int argc, char *argv[])
{
QApplication app(argc,argv);
MyApp obj;
obj.show();

return app.exec();
}

It gave me following error-

error main.cpp.7.there is no call for MyApp::MyApp()
candidates for the call are MyApp::MyApp(QWidget *parent,const char *name,
WFlags fl);
candidates to the call are MyApp::MyApp(const MyApp&);

Also when i tried this..

MyApp obj=new MyApp;
or
MyApp obj= new MyApp();
or 
MyApp obj=new MyApp(ListView,"myapp");

it gave the same error!!!!

what to do???

andromeda
when you put you application with ftp, select binary.

eddylau
Dear andromeda,

They are talking x86-qtopia application, not arm-qtopia application.
There is no need to put the application to target board with ftp!

Thanks

Eddy

Yayati Ekbote
Got it guys...
The problem wasn't in main() but was in implementation....I was declaring
pointers without creating objects!!!Now it works fine!!!
Thanks!!!