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. Q_PROPERTY - write function for multiple property
Forum Updated to NodeBB v4.3 + New Features

Q_PROPERTY - write function for multiple property

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 528 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.
  • P Offline
    P Offline
    poucz
    wrote on last edited by
    #1

    Hello,

    I have array of int variables.
    This array I sync with other PC.

    I export value as property to show in QML:

    Q_PROPERTY(int delay		        MEMBER delay		NOTIFY delayChange )
    Q_PROPERTY(int temp			MEMBER temp		NOTIFY tempChange )
    

    It's work perfectly.
    Now I need to, on some variable, be able to change value. So I append WRITE:

    Q_PROPERTY(int delay		MEMBER delay	WRITE delayWrite	NOTIFY delayChange )
    Q_PROPERTY(int temp		MEMBER temp	WRITE tempWrite		NOTIFY tempChange )
    

    It's working but in my implementaion Write function I call same function for all variable - changeVariable(int position, int value). Only change position -position is position in synced array.

    So I need write lot of trivial function - Is any option how to do it? Some addicional argument to WRITE function?

    Thank you

    J.HilkJ 1 Reply Last reply
    0
    • P poucz

      Hello,

      I have array of int variables.
      This array I sync with other PC.

      I export value as property to show in QML:

      Q_PROPERTY(int delay		        MEMBER delay		NOTIFY delayChange )
      Q_PROPERTY(int temp			MEMBER temp		NOTIFY tempChange )
      

      It's work perfectly.
      Now I need to, on some variable, be able to change value. So I append WRITE:

      Q_PROPERTY(int delay		MEMBER delay	WRITE delayWrite	NOTIFY delayChange )
      Q_PROPERTY(int temp		MEMBER temp	WRITE tempWrite		NOTIFY tempChange )
      

      It's working but in my implementaion Write function I call same function for all variable - changeVariable(int position, int value). Only change position -position is position in synced array.

      So I need write lot of trivial function - Is any option how to do it? Some addicional argument to WRITE function?

      Thank you

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @poucz I would suggest, if you're using QtCreator:

      Right click in Q_PROPERTY -> Refactor -> Generate Missing Q_PROPERTY members

      I use it all the time. It won't work for your quite as well, as you have an array as underlying data structure.


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      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