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. Anyways to store int or double by reference within QVariant?
Forum Updated to NodeBB v4.3 + New Features

Anyways to store int or double by reference within QVariant?

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

    Hello, I'm still trying to learn Qt. In my project I have a QVariantMap that my qml will be accessing. The values for each key are QVariants of int values. As I understand it, when it comes to primitives like int or double, QVariant will store the value rather than the reference. This is problematic because those int values come from another one of my classes members. So when the other class changes its values, it will not be reflected in my QVariantMap because it just made a copy of them rather than a reference to them.

    Am I understanding this correctly? If so, is there any way to get QVariant to store primitives like int or double by reference rather than value?

    jsulmJ 1 Reply Last reply
    0
    • L learis

      Hello, I'm still trying to learn Qt. In my project I have a QVariantMap that my qml will be accessing. The values for each key are QVariants of int values. As I understand it, when it comes to primitives like int or double, QVariant will store the value rather than the reference. This is problematic because those int values come from another one of my classes members. So when the other class changes its values, it will not be reflected in my QVariantMap because it just made a copy of them rather than a reference to them.

      Am I understanding this correctly? If so, is there any way to get QVariant to store primitives like int or double by reference rather than value?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @learis said in Anyways to store int or double by reference within QVariant?:

      Am I understanding this correctly?

      Yes, and there is no way to store references in a QVariant.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2

      • Login

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