Thanks for answer. I want to write a program to N8 mobile phone which would read accelerometer data and show value on screen at Label.
I have this code:
Qt Code:
  1. #include "mainwindow.h"
  2.  
  3. #include <QtGui/QApplication>
  4.  
  5. #include <stdio.h>
  6.  
  7. #define ACCELEROMETER_FILE_N900 "/sys/class/i2c-adapter/i2c-3/3-001d/coord"
  8.  
  9. class Accelerometer {
  10. int x;
  11. int y;
  12. int z;
  13.  
  14. public:
  15. Accelerometer() : x(0), y(0), z(0)
  16. {
  17. update();
  18. }
  19.  
  20. bool update()
  21. {
  22. int tmp[3] = {0, 0, 0};
  23. FILE *fd;
  24.  
  25. if (!(fd = fopen(ACCELEROMETER_FILE_N900, "r"))) {
  26. return false;
  27. }
  28.  
  29. if (fscanf(fd, "%i %i %i", tmp, tmp+1, tmp+2) != 3) {
  30. return false;
  31. }
  32.  
  33. if (fclose(fd) == EOF) {
  34. return false;
  35. }
  36.  
  37. x = tmp[0];
  38. y = tmp[1];
  39. z = tmp[2];
  40.  
  41. //How to change this?
  42. writeln('x=%i',x);
  43. return true;
  44. }
  45.  
  46. int getX() { return x; }
  47. int getY() { return y; }
  48. int getZ() { return z; }
  49.  
  50.  
  51. };
  52.  
  53.  
  54. int main(int argc, char *argv[])
  55. {
  56. QApplication app(argc, argv);
  57. MainWindow mainWindow;
  58. mainWindow.setOrientation(MainWindow::ScreenOrientationAuto);
  59. mainWindow.showExpanded();
  60. return app.exec();
  61. }
To copy to clipboard, switch view to plain text mode 
The object name of label is label_2. Which code do I have to write to change Label2 text to accelerometer X value? Or what else do I have to write? Or do you have any examples of codes which show on smartphone view acceleration values with only one *.cpp file without any addidtional *.h files?