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. Multiple Q_PROPERTY in the same class
Forum Updated to NodeBB v4.3 + New Features

Multiple Q_PROPERTY in the same class

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 324 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.
  • J Offline
    J Offline
    JJLim
    wrote on last edited by
    #1

    May I know is it ok for us to have multiple Q_PROPERTY within the same class? So far it can work by returning the value in val and valTest to me correctly. However, I not sure is it ok to do this or not, so I would like to ask for your advice, thank you.

    Example is as shown below:

    class Animal:public QObject{
    Q_OBJECT
    Q_PROPERTY(int val READ val WRITE setVal NOTIFY valChanged)
    Q_PROPERTY(int valTest READ valTest WRITE setVal NOTIFY valChanged)

    public:
    
    // declaration of other func
    
    int val(){
        return //something
    }
    
    int valTest(){
        return //something
    }
    

    };

    eyllanescE 1 Reply Last reply
    0
    • J JJLim

      May I know is it ok for us to have multiple Q_PROPERTY within the same class? So far it can work by returning the value in val and valTest to me correctly. However, I not sure is it ok to do this or not, so I would like to ask for your advice, thank you.

      Example is as shown below:

      class Animal:public QObject{
      Q_OBJECT
      Q_PROPERTY(int val READ val WRITE setVal NOTIFY valChanged)
      Q_PROPERTY(int valTest READ valTest WRITE setVal NOTIFY valChanged)

      public:
      
      // declaration of other func
      
      int val(){
          return //something
      }
      
      int valTest(){
          return //something
      }
      

      };

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

      @JJLim You can have multiple Q_PROPERTY is the same QObject. The only weird thing is that you have the same setter.

      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
      0
      • J Offline
        J Offline
        JJLim
        wrote on last edited by
        #3

        I see....
        Ok got it, thanks for your information

        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