Hi, I'm trying to create a signal, but I can't see the code. I'm trying to prevent reading and writing to a file at the same time with QSetting. Is there perhaps another way? Thanks.

mainwindow.h

Qt Code:
  1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3.  
  4. #include <QtWidgets>
  5.  
  6. #include "parametres.h"
  7. #include "threadsondes.h"
  8. #include "gainable.h"
  9. #include "affichecons.h"
  10.  
  11. class MainWindow: public QWidget
  12. {
  13. Q_OBJECT
  14.  
  15. public:
  16. MainWindow(QWidget *parent = nullptr);
  17.  
  18. signals:
  19. void lectureEnCours(bool m_lecture);
To copy to clipboard, switch view to plain text mode 

mainwindow.cpp

Qt Code:
  1. #include "mainwindow.h"
  2.  
  3. MainWindow::MainWindow(QWidget *parent)
  4. :QWidget (parent)
  5. {
  6. connect(this, &MainWindow::lectureEnCours, &m_mainwindowThreadSondes, &ThreadSondes::onLitEnCours);
  7.  
  8. m_timer1 = new QTimer(this);
  9. m_timer1 ->start(m_timerTemps);
  10. connect(m_timer1, &QTimer::timeout, this, &MainWindow::lectureTemperatures);
  11. }
  12.  
  13. void MainWindow::lectureTemperatures()
  14. {
  15. qDebug() << "lectureTemperature() MainWindow";
  16.  
  17. emit lectureEnCours(true);
  18. }
To copy to clipboard, switch view to plain text mode 

threadsondes.h

Qt Code:
  1. #ifndef THREADSONDES_H
  2. #define THREADSONDES_H
  3.  
  4. #include <QThread>
  5.  
  6. #include <QObject>
  7.  
  8. #include "sondes.h"
  9.  
  10. class ThreadSondes: public QThread
  11. {
  12. Q_OBJECT
  13.  
  14. public:
  15. ThreadSondes();
  16.  
  17. bool lecture = false;
  18.  
  19. void lectureTemperaturesEnCours();
  20.  
  21. public slots:
  22. void onLitEnCours(bool m_lecture);
  23.  
  24. signals:
  25.  
  26. private:
  27. DS18b20 m_threadSondesDS18b20;
  28.  
  29. void run();
  30.  
  31. };
  32.  
  33. threadsondes.cpp
  34.  
  35. [CODE]
  36. #include "threadsondes.h"
  37.  
  38. #include <QDebug>
  39.  
  40. ThreadSondes::ThreadSondes()
  41. {
  42. qDebug() << "ThreadSondes";
  43. }
  44.  
  45. void ThreadSondes::onLitEnCours(bool m_lecture)
  46. {
  47. lecture = m_lecture;
  48. }
  49.  
  50. void ThreadSondes::lectureTemperaturesEnCours()
  51. {
  52. if (lecture == true) {
  53. qDebug() << "lecture = " << lecture;
  54. } else {
  55. qDebug() << "lecture = " << lecture;
  56. }
  57. }
  58.  
  59. void ThreadSondes::run()
  60. {
  61. while (1) {
  62.  
  63. qDebug() << "run ThreadSondes()";
  64.  
  65. lectureTemperaturesEnCours();
  66.  
  67. /*m_threadSondesDS18b20.lectureSondeExt(); // on ecrite dans parametres en meme temps
  68. m_threadSondesDS18b20.lectureSondeUnitExt();
  69. m_threadSondesDS18b20.lectureSondeEcExt();
  70. m_threadSondesDS18b20.lectureSondeUnitInt();
  71. m_threadSondesDS18b20.lectureSondeEcInt();
  72.  
  73. sleep(5);*/
  74. }
  75. }
To copy to clipboard, switch view to plain text mode 
[/CODE]