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. QQmlProperty loses data
Forum Updated to NodeBB v4.3 + New Features

QQmlProperty loses data

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

    Hello,

    I read some data from my database and create a model instance from that data.
    One attribute on that class is a QQmlPropertyMap. After returning the created model instance from the function where I read the data and create the instance, the data inside the QQmlPropertyMap is lost.

    I assume the reason for that is, that the QQmlPropertyMap data is actually a QScopedPointer as seen in the screenshot below:
    c58ba1b8-4dc5-4ede-a0eb-1207a00e5b78-image.png

    How can I keep the QQmlPropertyMap populated when I return the surrounding object from my function?

    What exactly am I doing?

    // read data from database happened prior in this function
    
    QQmlPropertyMap* airEjMapping =
          createQQmlPropertyMapFromString(
               m->getAttribute("airEjectionMapping").value<QString>());
    
       // Create object
       Mp* mp = new Mp(m->getAttribute("id").value<qint32>(),
       airEjMapping);
    
       return mp;
    
    
    // Mp ctor
    Mp::Mp(const qint32 id,
        QQmlPropertyMap* airEjMapping
        : m_id(id)
     {
       // I save the QQmlProperty as QSharedPointer
       m_airEjectionMapping.reset(airEjMapping);
     }
    

    After returning the contents of that property looks like this
    ec575fb1-d472-4c20-b099-0b40ae15103a-image.png

    Now, how am I supposed to pass my model through my application without losing data?

    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