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. QVariant::save: unable to save type
Forum Updated to NodeBB v4.3 + New Features

QVariant::save: unable to save type

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 3 Posters 990 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.
  • R Offline
    R Offline
    Redman
    wrote on last edited by Redman
    #1
    struct  Myclass {
    QString key{};
    };
    

    main.cpp

    qRegisterMetaType<QList<QSharedPointer<MyClass>>>();
    

    Results in QVariant::save: unable to save type 'QList<QSharedPointer<MyClass>>' (type id: 65560)

    ASSERT failure in QVariant::save: "Invalid type to save", file C:\Users\qt\work\qt\qtbase\src\corelib\kernel\qvariant.cpp, line 1376
    

    That line tries to "save" an object of that type into a stream but fales.

    I defined stream operators for that type aswell
    Anyone knows where the error is

    jsulmJ Pl45m4P 2 Replies Last reply
    0
    • R Redman
      struct  Myclass {
      QString key{};
      };
      

      main.cpp

      qRegisterMetaType<QList<QSharedPointer<MyClass>>>();
      

      Results in QVariant::save: unable to save type 'QList<QSharedPointer<MyClass>>' (type id: 65560)

      ASSERT failure in QVariant::save: "Invalid type to save", file C:\Users\qt\work\qt\qtbase\src\corelib\kernel\qvariant.cpp, line 1376
      

      That line tries to "save" an object of that type into a stream but fales.

      I defined stream operators for that type aswell
      Anyone knows where the error is

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

      @Redman Why do you want to serialise pointers?

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

      1 Reply Last reply
      3
      • R Redman
        struct  Myclass {
        QString key{};
        };
        

        main.cpp

        qRegisterMetaType<QList<QSharedPointer<MyClass>>>();
        

        Results in QVariant::save: unable to save type 'QList<QSharedPointer<MyClass>>' (type id: 65560)

        ASSERT failure in QVariant::save: "Invalid type to save", file C:\Users\qt\work\qt\qtbase\src\corelib\kernel\qvariant.cpp, line 1376
        

        That line tries to "save" an object of that type into a stream but fales.

        I defined stream operators for that type aswell
        Anyone knows where the error is

        Pl45m4P Offline
        Pl45m4P Offline
        Pl45m4
        wrote on last edited by
        #3

        @Redman

        Change to

        qRegisterMetaType<QList<MyClass>>();
        

        if you want a metaType QList of MyClass items.


        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

        ~E. W. Dijkstra

        1 Reply Last reply
        0
        • R Redman 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