Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8895357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:45:19+00:00 2026-06-14T23:45:19+00:00

QVariant::DataPtr is private, and yesterday I used QBitArray to do some work. There’s a

  • 0

QVariant::DataPtr is private, and yesterday I used QBitArray to do some work. There’s a function data_ptr() returning DataPtr&, but I don’t know when and how to use this function. I write the returning data to a file and opened it in ST2, there shows an SOH:

int main()
{
    QBitArray bit(8);
    bit[5] = true; //--> I tried bit[7] = true; result is `SOH` still
    QFile file("out");
    file.open(QIODevice::WriteOnly);
    QDataStream outs(&file);
    outs << bit.data_ptr();
    file.close();
    return 0;
}

I know SOH is the meaning of Start Of Header, and it is defined as 0x01(1byte) for frame delimiting. First I wrote bit[7]=true; so I thought bit.data_ptr() may be the raw data(00000001 in binary) in bit which is an encapsulated QBitArray. But when I tried bit[5]=true; and opened the file in ST2, it still shew SOH. So I’m confused.
enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T23:45:21+00:00Added an answer on June 14, 2026 at 11:45 pm

    DataPtr is just a pointer to Data structure. The structure is made private, so you shouldn’t use it for anything. However, you can use pointer to it to discriminate two byte arrays. Use QBitArray::operator<<() to write bit array into a data stream.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make a unit-test for a function returning a qvariant to make
QVariant (needed for QSettings class) supports creation from QMap<QString, QVariant> But trying to initialise
I have a custom type I'd like to use with QVariant but I don't
According to the Qt documentation, QVariant::operator== does not work as one might expect if
is there a quick way to read record from query as a QMap<QString,QVariant> or
I have stored QStringList in a QVariant variable while calling setData function. Now I'd
What is a QVariant and when should it be used?
Situation I have a QList<QVariant> where each QVariant item should be a QList<QVariant> of
#include <QtCore/QCoreApplication> #include <QVariant> #include <QtDebug> int main(int argc, char *argv[]) { QCoreApplication a(argc,
QVariant appears to accept QList<QVariant> and not QVector<QVariant> nor QLinkedList<QVariant> . Is it simply

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.