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&#40;QLatin1String("qml/RMX16_First/main.qml"&#41;&#41;;
    viewer.showExpanded();
    return app->exec&#40;&#41;;
    

    }
    @
    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]


  • Moderators

    What line is the error occurring on?



  • Line 18

    How did you tidy that code up please?


  • Moderators

    Try adding "public" before QObject in line 3 of crmx16.h.



  • Alas, to no avail. Same error.

    main.cpp:18: error:

    C2243: 'type cast' : conversion from 'CRMX16 *' to 'QObject *' exists, but is inaccessible



  • DOH!!! Of course it works fine.

    Loads of different errors to work on now. Thanks for the help!


  • Moderators

    Be sure and add [Solved] to the thread title your initial post, please. Thanks!


  • Moderators

    [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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.