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

  • SEARCH
  • Home
  • 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 691007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:29:42+00:00 2026-05-14T02:29:42+00:00

I have a an object I’d like to be able to read and write

  • 0

I have a an object I’d like to be able to read and write to/from a QDataStream. The header is as follows:

class Compound
{
public:
    Compound(QString, QPixmap*, Ui::MainWindow*);
    void saveCurrentInfo();
    void restoreSavedInfo(QGraphicsScene*);

    void setImage(QPixmap*);

    QString getName();

private:
    QString name, homeNotes, addNotes, expText;
    Ui::MainWindow *gui;
    QPixmap *image;        

    struct NMRdata
    {
        QString hnmrText, cnmrText, hn_nmrText, hn_nmrNucl, notes;
        int hnmrFreqIndex, cnmrFreqIndex, hn_nmrFreqIndex,
        hnmrSolvIndex, cnmrSolvIndex, hn_nmrSolvIndex;
    }*nmr_data;

    struct IRdata
    {
        QString uvConc, lowResMethod,
            irText, uvText, lowResText, highResText,
            highResCalc, highResFnd, highResFrmla,
            notes;
    int irSolvIndex, uvSolvIndex;
    }*ir_data;

    struct PhysicalData
    {
        QString mpEdit, bpEdit, mpParensEdit, bpParensEdit,
            rfEdit, phyText, optAlpha,
            optConc, elemText, elemFrmla,
            notes;
        int phySolvIndex, optSolvIndex;
    }*physical_data;   
};

For all intents and purposes, the class just serves as an abstraction for a handful of QStrings and a QPixmap. Ideally, I would be able to write a QList to a QDataStream but I’m not exactly sure how to go about doing this.

If operator overloading is a suitable solution, would writing code like

friend QDataStream& operator << (QDataStream&,Compound) { ... }

be a potential solution? I’m very open to suggestions! Please let me know if any further clarification is needed.

  • 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-05-14T02:29:43+00:00Added an answer on May 14, 2026 at 2:29 am

    I think you’ve answered your own question! The stream operator

    QDataStream& operator<<( QDataStream&, const Compound& )
    

    will work fine. In the implementation you just use the existing stream operators on QDataStream to serialise the individual bits of your Compound. Some Qt classes define non-member QDataStream operators too. QString is one and so is QList so it looks like you’re sorted!

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

Sidebar

Related Questions

While exercising your DDD skills, suppose you have object like this: class Person {
I think I read somewhere that some modules only have object oriented interfaces (
We have Object and ValueType .... And String .... String is derived from object,
Does does class/object models have a out-of-the-box equivalent to a database foreign key constraint?
I have object A and object B deserialized from binary files. B has a
Lets say I have object Tom which has class Person. Class Person String Name
Here is the situation I am struggling with. I have an Object Model: public
i have object like this: some_object this object has like 1000 properties. i would
Can I have object with the same name as class in javascript?
I have object XML serialized messages coming into a class called MessageRouter . The

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.