error: C2243: 'type cast' : conversion from 'CRMX16 *' to 'QObject *' exists, but is inaccessible
-
I need some help with this one.
mail.qml
@
#include <QtGui/QApplication>
#include <qdeclarativecontext.h>
#include "qmlapplicationviewer.h"
#include "crmx16.h"Q_DECL_EXPORT int main(int argc, char *argv[])
{QScopedPointer<QApplication> app(createApplication(argc, argv)); QmlApplicationViewer viewer; QDeclarativeContext *context = viewer.rootContext(); CRMX16 RMX16; context->setContextProperty("CRMX16", &RMX16); viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto); viewer.setMainQmlFile(QLatin1String("qml/RMX16_First/main.qml")); viewer.showExpanded(); return app->exec();
}
@
crmx16.h
@
#include <qobject.h>class CRMX16 : QObject
{
Q_OBJECT
public:
CRMX16();~CRMX16() {} bool DecayTimePressed () { return m_DecayTimePressed; } void ToggleDecayTime () { m_DecayTimePressed = m_DecayTimePressed ? false : true; }
private:
bool m_DecayTimePressed;
bool m_PreDelayPressed;
public slots:
void getPreDelay (bool State);
void getDecayTime (bool State);
signals:
void setPreDelay (bool State) {}void setDecayTime (bool State) {}
};
@
crmx16.cpp
@
#include "crmx16.h"CRMX16::CRMX16()
{
m_DecayTimePressed = false;
m_PreDelayPressed = false;
}void CRMX16::getDecayTime (bool State)
{
m_DecayTimePressed = State;
if (m_DecayTimePressed) {
if (m_PreDelayPressed)
emit setPreDelay(false);
}
}void CRMX16::getPreDelay (bool State)
{
m_PreDelayPressed = State;
if (m_PreDelayPressed) {
if (m_DecayTimePressed)
emit setDecayTime(false);
}}
@[Edit: Be sure and add @ tags for code -- mlong]
-
Try adding "public" before QObject in line 3 of crmx16.h.
-
[quote author="Thingfish" date="1346334176"]Line 18
How did you tidy that code up please?[/quote]
mlong used the code tags. have a look at "the forum help":http://qt-project.org/wiki/ForumHelp#e3f82045ad0f480d3fb9e0ac2d58fb01