Advertisement
AbraaoAllysson

Utility.cpp]

Aug 16th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include "utility.h"
  2.  
  3. Utility::Utility()
  4. {
  5.  
  6. }
  7.  
  8. QString Utility::statusBatteryLaptop()
  9. {
  10. std::ifstream myFile("/sys/class/power_supply/BAT0/capacity");
  11.  
  12. QString line ;
  13. if(myFile.is_open())
  14. {
  15. std::string str;
  16. while (getline(myFile,str) )
  17. {
  18. line = QString::fromLocal8Bit(str.c_str());
  19. }
  20. myFile.close();
  21. }
  22. else
  23. {
  24. qDebug() << "Unable to open file";
  25. }
  26.  
  27.  
  28. return line;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement