Creating an object of QDeclarativeView results in segmentation fault
.h
Code:
#include <QObject>
#include <QDebug>
{
Q_OBJECT
public:
Q_INVOKABLE
void cppMethod
(const QString &msg
) {
qDebug() << "Called the C++ method with" << msg;
}
public slots:
void cppSlot (int number)
{
qDebug() << "Called the C++ slot with" << number;
}
};
.cpp
Code:
#include <QtCore/QCoreApplication>
#include <QDeclarativeEngine>
#include <QDeclarativeComponent>
#include <QDeclarativeContext>
#include <QDeclarativeView>
#include <QVariant>
#include <QMetaObject>
#include "cppFromQml.h"
int main (int argc, char *argv[])
{
QDeclarativeView view;
return a.exec();
}
This results in segmentation fault. What's the way out?
Qt: 4.8.1
Re: Creating an object of QDeclarativeView results in segmentation fault
QDeclarativeView is a widget. Widgets need a QApplication instance. You have a QCoreApplication instance.
Cheers,
_
Re: Creating an object of QDeclarativeView results in segmentation fault