Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. error: C2243: 'type cast' : conversion from 'CRMX16 *' to 'QObject *' exists, but is inaccessible
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved General and Desktop
8 Posts 4 Posters 6.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Thingfish
    wrote on last edited by
    #1

    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]

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mlong
      wrote on last edited by
      #2

      What line is the error occurring on?

      Software Engineer
      My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

      1 Reply Last reply
      0
      • T Offline
        T Offline
        Thingfish
        wrote on last edited by
        #3

        Line 18

        How did you tidy that code up please?

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tobias.hunger
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0
          • T Offline
            T Offline
            Thingfish
            wrote on last edited by
            #5

            Alas, to no avail. Same error.

            main.cpp:18: error:

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

            1 Reply Last reply
            0
            • T Offline
              T Offline
              Thingfish
              wrote on last edited by
              #6

              DOH!!! Of course it works fine.

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

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mlong
                wrote on last edited by
                #7

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

                Software Engineer
                My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  koahnig
                  wrote on last edited by
                  #8

                  [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

                  Vote the answer(s) that helped you to solve your issue(s)

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved