Created
December 16, 2015 20:49
-
-
Save alex-pat/8295126c40e270c50caf to your computer and use it in GitHub Desktop.
QDataStream example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Manager::saveData() { | |
QFile settings ("sbsettings"); | |
if ( settings.open ( QIODevice::WriteOnly ) == false ) { | |
std::cerr << "Cannot open settings" << std::endl; | |
exit(1); | |
} | |
QDataStream stngs (&settings); | |
int size = profiles.size(); | |
stngs << size | |
<< currentProfile; | |
for (int i = 0; i < size; i++) | |
stngs << *(profiles[i]); | |
} | |
void Manager::loadData() { | |
QFile settings ("sbsettings"); | |
if ( settings.open ( QIODevice::ReadOnly ) == false ) { | |
std::cerr << "Cannot open settings" << std::endl; | |
exit(1); | |
} | |
QDataStream stngs (&settings); | |
int size; | |
stngs >> size | |
>> currentProfile; | |
for (int i = 0; i < size; i++) { | |
Profile* prof = new Profile; | |
stngs >> prof; | |
profiles.push_back( prof ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment