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 returning enum type
Forum Updated to NodeBB v4.3 + New Features

Error returning enum type

Scheduled Pinned Locked Moved Solved General and Desktop
error
7 Posts 2 Posters 2.0k Views 2 Watching
  • 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.
  • yuvaramY Offline
    yuvaramY Offline
    yuvaram
    wrote on last edited by
    #1

    Hi,

    class myclass : public QObject
    {
    Q_OBJECT
    Q_ENUMS(E_Priority)
    Q_PROPERTY(E_Priority priorityFunc READ getpriorityFunc WRITE setpriorityFunc NOTIFY SIGpriorityChanged)
    public:
    enum E_Priority { High, Low, VeryHigh, VeryLow };
    explicit myclass(QObject *parent = 0);
    E_Priority getpriorityFunc()const;
    void setpriorityFunc(E_Priority prpt);

    signals:
    void SIGpriorityChanged(E_Priority);

    public slots:
    private:
    E_Priority m_priority;
    };

    myclass::myclass(QObject *parent) : QObject(parent)
    {
    qDebug()<<Q_FUNC_INFO<<endl;
    }

    E_Priority myclass:: getpriorityFunc(){
    qDebug()<<Q_FUNC_INFO<<endl;
    return m_priority;
    }

    void myclass:: setpriorityFunc(E_Priority prpt){
    qDebug()<<Q_FUNC_INFO<<endl;
    m_priority = prpt;
    emit SIGpriorityChanged(m_priority);
    }

    There is a error : 'E_Priority' does not name type.

    Yuvaram Aligeti
    Embedded Qt Developer
    : )

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by Chris Kawa
      #2

      E_Priority is not known in the global scope, thus when declaring a function that returns it you should scope it to the class it is declared in:

      myclass::E_Priority myclass::getpriorityFunc(){
      ...
      

      Btw. please surround your code with ```. It makes it a lot easier to read.

      yuvaramY 1 Reply Last reply
      0
      • Chris KawaC Chris Kawa

        E_Priority is not known in the global scope, thus when declaring a function that returns it you should scope it to the class it is declared in:

        myclass::E_Priority myclass::getpriorityFunc(){
        ...
        

        Btw. please surround your code with ```. It makes it a lot easier to read.

        yuvaramY Offline
        yuvaramY Offline
        yuvaram
        wrote on last edited by
        #3

        @Chris-Kawa
        Thank you.
        But there is Prototype miss match error

        Yuvaram Aligeti
        Embedded Qt Developer
        : )

        1 Reply Last reply
        0
        • Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #4

          That doesn't tell much. Can you post the full error and the code that generates it?

          yuvaramY 1 Reply Last reply
          0
          • Chris KawaC Chris Kawa

            That doesn't tell much. Can you post the full error and the code that generates it?

            yuvaramY Offline
            yuvaramY Offline
            yuvaram
            wrote on last edited by
            #5

            @Chris-Kawa
            Code is already share in above post.

            myclass.cpp:8: error: prototype for 'myclass::E_Priority myclass::getpriorityFunc()' does not match any in class 'myclass'
            myclass::E_Priority myclass:: getpriorityFunc(){
            ^

            Yuvaram Aligeti
            Embedded Qt Developer
            : )

            1 Reply Last reply
            0
            • Chris KawaC Offline
              Chris KawaC Offline
              Chris Kawa
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Ok, your function is declared const in the header but non-const in the definition. Should be:

              myclass::E_Priority myclass::getpriorityFunc() const {
              ...
              
              yuvaramY 1 Reply Last reply
              2
              • Chris KawaC Chris Kawa

                Ok, your function is declared const in the header but non-const in the definition. Should be:

                myclass::E_Priority myclass::getpriorityFunc() const {
                ...
                
                yuvaramY Offline
                yuvaramY Offline
                yuvaram
                wrote on last edited by
                #7

                @Chris-Kawa
                Thank you :)

                Yuvaram Aligeti
                Embedded Qt Developer
                : )

                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