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. Generate assert failure when qmodelindex is put into qdatastream...

Generate assert failure when qmodelindex is put into qdatastream...

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

    Hi,

    I am trying to put qmodelindex into qdatastream and I get the following error:

    What should I do?

    < source >
    QVariant v(model_Idx);
    QByteArray ba;
    QDataStream ds(&ba, QIODevice::ReadWrite);

    ds << v;    
    

    <error>
    Debug Error!
    Module : 5.7.1
    File : global\gglobal.cpp
    Line:3089
    ASSERT failure in QVariant::save "Invalid type to save", file kernel\qvariant.cpp, line 2144

    Bye...

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      I don't think QModelIndex storing in stream is supported. Since save operation returns false for QModelIndex, it must be crashing. May be you can get the row,column values from QModelIndex and save them in stream. Also as side note, it is not a good idea to store the QModelIndex. See the warning message in Qt documentation for QModelIndex.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      3

      • Login

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