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. Automatically incrementing unique ID for a QML items
Forum Updated to NodeBB v4.3 + New Features

Automatically incrementing unique ID for a QML items

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 203 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.
  • S Offline
    S Offline
    St.Stanislav
    wrote on last edited by
    #1

    Hello everyone!

    I wonder about the best practices to use (implement) Automatically incrementing unique ID for QML items (if it's possible ofc). What I mean: let's suppose that there are different custom buttons in the whole project (in the different QML files and items). Every button should be connected to some c++ pointer. So I use C++ map, where the value is a pointer and the key is Q_ENUM. So I can manually set this Q_ENUM for each custom button and work with pointers via the mapping. Can this process be simplified or made more flexible? I thought about some static functions/variables in a QML singleton, but I'm not sure if this is a good practice. Moreover, I'm not sure, can it even be done correctly (as I suppose the QML items loading order is not strictly defined, so the unique IDs can be different within different program launches).

    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