Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Generate assert failure when qmodelindex is put into qdatastream...
Qt 6.12 LTS is out! See what's new in the release blog

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 1.2k 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
      Moderators Qt Champions 2024 Qt Champions 2022 Qt Champions 2017
      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
      https://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
      • Unsolved