Created
May 5, 2018 19:16
-
-
Save foxoman/9fead94ad4e24e09237c6dfc1a9d088e to your computer and use it in GitHub Desktop.
File Stream Example in Qt
This file contains hidden or 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
#include <QtCore> | |
#include <io.hpp> | |
int main (int argc, char** argv) { | |
QCoreApplication app (argc, argv); | |
const QString WELCOME = R"( | |
+=====================================================+ | |
:: CPU INFORMATION :: | |
+=====================================================+ | |
*** BY SULTAN AL ISSAI || @foxoman 2018 *** | |
)"; | |
qPrint << CYN << BLD << WELCOME << RST << endl; | |
QFile file ("/proc/cpuinfo"); | |
file.open (QIODevice::ReadOnly | QIODevice::Text); | |
QTextStream in (&file); | |
QString line = in.readLine (); | |
while (!line.isNull ()) { | |
line = in.readLine (); | |
int index = line.indexOf (":"); | |
if (line.contains ("vendor_id")) { | |
qPrint << BLD << BLU << "VenderID:" << RST << line.mid (index + 1, -1) << endl; | |
qPrint << endl; | |
} | |
if (line.contains ("model name")) { | |
qPrint << BLD << YEL << "ModelName:" << RST << line.mid (index + 1, -1) << endl; | |
qPrint << endl; | |
} | |
if (line.contains ("flags")) { | |
qPrint << BLD << GRN << "Flags:" << RST << line.mid (index + 1, -1) << endl; | |
qPrint << endl; | |
} | |
if (line.contains ("bugs")) { | |
qPrint << BLD << RED << "Bugs:" << RST << line.mid (index + 1, -1) << endl; | |
qPrint << endl; | |
break; | |
} | |
} | |
file.close (); | |
QTimer::singleShot (0, &app, &QCoreApplication::quit); | |
return app.exec (); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment