的QDataStream << and >>运算符我有一个目的,我想能够读取并从操作QDataStream写入/。标题如下:重载用于用户定义类型
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;
};
对于所有意图和目的,类只是充当将QString和QPixmap的极少数的抽象。理想情况下,我将能够到的QList写入操作QDataStream,但我不完全知道如何去这样做。
如果操作符重载是一个合适的解决方案,会写像
friend QDataStream& operator << (QDataStream&,Compound) { ... }
代码是一个潜在的解决方案吗?我非常乐于提供建议!请让我知道是否需要进一步澄清。
“意图和目的” – 2012-01-09 21:10:24