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. How to bind multiple c++ values to qml properties?
Qt 6.11 is out! See what's new in the release blog

How to bind multiple c++ values to qml properties?

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 306 Views 1 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.
  • C Offline
    C Offline
    Creaperdown
    wrote on last edited by
    #1

    Hey, I am currently working on a settings system for my application and I am having some problems binding Qml properties to the stored values on the C++ side. I hope someone here might have an idea on how to solve this problem elegantly.

    I have one "Service" class that encapsulates a QSettings object, providing a "getSetting()" and "setSetting()" function and one "Controller" class that I register to QML to be able to write and read to/from the stored settings by accessing that "Service" class.
    Now on my QML side, I'd like to bind each of my setting dependent properties to the corresponding setting, so that if I change a setting via. "setSetting(x)", my QML property is automatically updated.

    What are my possibilities here? Would I need to define a Q_PROPERTY for each and every setting I have (I have ~100+) and implement the get/set/notify function, or is there something else I could do?

    Thanks for any help in advance.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Creaperdown
      wrote on last edited by
      #2

      I've come across QQmlPropertyMap and it seems to be a decent, dynamic solution to my problem.

      1 Reply Last reply
      0
      • C Creaperdown has marked this topic as solved on

      • Login

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