Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. TypeError: Property '...' of object ...(0x55fcc300c0d0) is not a function
Forum Updated to NodeBB v4.3 + New Features

TypeError: Property '...' of object ...(0x55fcc300c0d0) is not a function

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 1.7k 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.
  • M Offline
    M Offline
    Meistermosher
    wrote on last edited by
    #1

    Re: TypeError: Property '' of object QObject(0x6cfdf0) is not a function

    Ok, I'm getting rather mad on this.
    I just want to get a value of a bool im my C++ class:

    #ifndef HPC_MANAGER_H
    #define HPC_MANAGER_H
    
    #include <QObject>
    #include <QDebug>
    
    class hpc_manager : public QObject
    {
        Q_OBJECT
    private:
        bool occupiedOne = false;
        bool occupiedTwo = false;
        bool occupiedThree = false;
    
        int occupiedSlots = 0;
    
    public:
        explicit hpc_manager(QObject *parent = nullptr);
        bool chargerIsOccupied();
        int getOccupiedSlots();
    
    
    signals:
    
    public slots:
        void set_current_charger(int cs);
    
    
    };
    
    #endif // HPC_MANAGER_H
    

    I think I've set it up all right here...

    #include "hpc_manager.h"
    
    hpc_manager::hpc_manager(QObject *parent) : QObject(parent)
    {
    
    }
    
    bool hpc_manager::chargerIsOccupied()
    {
        if(occupiedOne && occupiedTwo)
            return true;
        else if(occupiedOne && occupiedThree)
            return true;
        else if(occupiedTwo && occupiedThree)
            return true;
        else
            return false;
    }
    
    int hpc_manager::getOccupiedSlots()
    {
        return occupiedSlots;
    }
    

    The int was just my last hope for this...

    But everytime I try to get the infos within my Qml:

        function slotSelected(id)
        {
            //console.log(hpcManager.getOccupiedSlots())
            if(hpcManager.getOccupiedSlots === 2)
            {
                hpcManager.set_current_charger(id)
                t.running = false
            }
            else
                console.log("All Chargers are occupied!");
        }
    

    I get this "qrc:/WelcomeScreen.qml:73: TypeError: Property 'getOccupiedSlots' of object hpc_manager(0x55fcc300c0d0) is not a function"
    Error. I tried different stuff like !== or so... but it's either unknown or simply just says "All chargers are occupied", but this can't be, because the value is set to "0" at the beginning.

    What am I missing here?

    eyllanescE 1 Reply Last reply
    0
    • M Meistermosher

      Re: TypeError: Property '' of object QObject(0x6cfdf0) is not a function

      Ok, I'm getting rather mad on this.
      I just want to get a value of a bool im my C++ class:

      #ifndef HPC_MANAGER_H
      #define HPC_MANAGER_H
      
      #include <QObject>
      #include <QDebug>
      
      class hpc_manager : public QObject
      {
          Q_OBJECT
      private:
          bool occupiedOne = false;
          bool occupiedTwo = false;
          bool occupiedThree = false;
      
          int occupiedSlots = 0;
      
      public:
          explicit hpc_manager(QObject *parent = nullptr);
          bool chargerIsOccupied();
          int getOccupiedSlots();
      
      
      signals:
      
      public slots:
          void set_current_charger(int cs);
      
      
      };
      
      #endif // HPC_MANAGER_H
      

      I think I've set it up all right here...

      #include "hpc_manager.h"
      
      hpc_manager::hpc_manager(QObject *parent) : QObject(parent)
      {
      
      }
      
      bool hpc_manager::chargerIsOccupied()
      {
          if(occupiedOne && occupiedTwo)
              return true;
          else if(occupiedOne && occupiedThree)
              return true;
          else if(occupiedTwo && occupiedThree)
              return true;
          else
              return false;
      }
      
      int hpc_manager::getOccupiedSlots()
      {
          return occupiedSlots;
      }
      

      The int was just my last hope for this...

      But everytime I try to get the infos within my Qml:

          function slotSelected(id)
          {
              //console.log(hpcManager.getOccupiedSlots())
              if(hpcManager.getOccupiedSlots === 2)
              {
                  hpcManager.set_current_charger(id)
                  t.running = false
              }
              else
                  console.log("All Chargers are occupied!");
          }
      

      I get this "qrc:/WelcomeScreen.qml:73: TypeError: Property 'getOccupiedSlots' of object hpc_manager(0x55fcc300c0d0) is not a function"
      Error. I tried different stuff like !== or so... but it's either unknown or simply just says "All chargers are occupied", but this can't be, because the value is set to "0" at the beginning.

      What am I missing here?

      eyllanescE Offline
      eyllanescE Offline
      eyllanesc
      wrote on last edited by eyllanesc
      #2

      @Meistermosher To expose a function to C++ use Q_INVOKABLE or use a slot, for this change to:

      Q_INVOKABLE int getOccupiedSlots();
      

      and

      if(hpcManager.getOccupiedSlots() == 2)
      

      Please read the docs: https://doc.qt.io/qt-5/qtqml-cppintegration-exposecppattributes.html#exposing-methods-including-qt-slots

      If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

      1 Reply Last reply
      3
      • M Offline
        M Offline
        Meistermosher
        wrote on last edited by
        #3

        You, sir, are my rescue! :)
        Thanks a lot! This saved me a lot of headache.

        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