Page 2 of 2 FirstFirst 12
Results 21 to 27 of 27

Thread: QLabel QPixmap change

  1. #21
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,287
    Thanks
    310
    Thanked 868 Times in 855 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QLabel QPixmap change

    I noticed that my gifs move in slow motion except during the reading of my probes
    I think you need to redesign your program. You are still executing GUI code from inside your Thread class (changing the QLCDNumber widgets), and as Lesiok said, your run() loop is completely consuming the CPU except during the processEvents() call. That is why your GIFs are slow.

    I do not know how your temperature sensors work. If there is a way to read a sensor only when there is data available, then setting up your run() loop so it checks for data and reads it only when necessary, that might help. If you don't need to read data constantly, then you could add a delay that reads data one time per second and then waits. That way, other parts of your program could run at full speed except when reading temperatures.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  2. #22
    Join Date
    Jan 2025
    Posts
    14
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QLabel QPixmap change

    yes indeed, I know that I still have the QLCDNUMBERs to make as a signal,

    and thanks for the info; I have a class that reads my probes, if you are ever interested in seeing it.

    Qt Code:
    1. #ifndef SONDES_H
    2. #define SONDES_H
    3.  
    4. #include "parametres.h"
    5.  
    6. #include <time.h>
    7. #include <inttypes.h>
    8. #include <string.h>
    9.  
    10. using namespace std;
    11.  
    12. #define MAX_DEVICES 12
    13.  
    14. struct ds18b20
    15. {
    16. char devPath [128];
    17. char devID [16];
    18. };
    19.  
    20. class DS18b20
    21. {
    22.  
    23. public:
    24. DS18b20();
    25.  
    26. Parametres *m_sondesParametres;
    27.  
    28. double tempExtLue = 00.00;
    29. double tempUnitExtLue = 00.00;
    30. double tempEcExtLue = 00.00;
    31. double tempUnitIntLue = 00.00;
    32. double tempEcIntLue = 00.00;
    33.  
    34. double consIntCa;
    35.  
    36. void lectureTemperatures();
    37.  
    38. private:
    39. int DS_COUNT;
    40. ds18b20 ds18b20_table [MAX_DEVICES];
    41.  
    42. void DS_FindDevices();
    43. void DS_CheckDevices();
    44. void DS_GetTemp(int DS_num,double *temp_str_data);
    45. int DS_get_num_devices();
    46.  
    47. unsigned long long departLectureSondes;
    48. unsigned short tempoLectureSondes = 5;
    49. time_t secondes = time(NULL);
    50.  
    51. };
    52. #endif // SONDES_H
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. #include <iostream>
    2. #include <unistd.h>
    3. #include <errno.h>
    4. #include <stdlib.h>
    5. #include <stdio.h>
    6. #include <string.h>
    7. #include <cstring>
    8. #include <time.h>
    9. #include <sys/time.h>
    10. #include <dirent.h>
    11. #include <QDebug>
    12.  
    13. using namespace std;
    14.  
    15. string DS_client[] = {"28-3ce1e3805e9f", "28-3ce1e3809744", "28-3ce1e38060ec", "28-3ce1e3801251", "28-3ce1e3804835"};
    16.  
    17. DS18b20::DS18b20()
    18. {
    19. qDebug() << "Sondes";
    20.  
    21. m_sondesParametres = new Parametres(QString("settings/parametres.ini"), QSettings::IniFormat);
    22.  
    23. DS_FindDevices();
    24. DS_CheckDevices();
    25. lectureTemperatures();
    26. }
    27.  
    28. void DS18b20::DS_GetTemp(int DS_num,double *temp_str_data)
    29. {
    30. #define SIZE 1
    31. #define NUMELEM 74
    32.  
    33. FILE *fp = NULL;
    34. char buff[100];
    35. char temp_raw[5];
    36.  
    37. //example buff output:
    38. //3f 01 4b 46 7f ff 7f 10 10 : crc=10 YES
    39. //3f 01 4b 46 7f ff 7f 10 10 t=19937
    40.  
    41. fp = fopen(ds18b20_table[DS_num].devPath,"r");
    42.  
    43. if (NULL == fp) {
    44. printf("\n DS fopen Error!!!\n\n");
    45. *temp_str_data = -127.00;
    46. return;
    47. }
    48.  
    49. if(SIZE * NUMELEM != fread(buff,SIZE,NUMELEM,fp)) {
    50. printf("\n DSx file read failed\n");
    51. *temp_str_data = -127.00;
    52. return;
    53. }
    54.  
    55. temp_raw[0] = buff[69];
    56. temp_raw[1] = buff[70];
    57. temp_raw[2] = buff[71];
    58. temp_raw[3] = buff[72];
    59. temp_raw[4] = buff[73];
    60. temp_raw[5] = buff[74];
    61.  
    62.  
    63. if(string(buff).find("YES") == string::npos) { //crc error
    64. printf("\n DS CRC failed\n");
    65. *temp_str_data = -127.000;
    66. fclose(fp);
    67. return;
    68. }
    69.  
    70. *temp_str_data = atof(temp_raw) / 1000;
    71. fclose(fp);
    72. }
    73.  
    74. void DS18b20::DS_CheckDevices()
    75. {
    76. int x = 0;
    77. int y = 0;
    78. for(x = 0; x < DS_COUNT; x++) {
    79. printf("%s\n",ds18b20_table[x].devID);
    80. }
    81.  
    82. printf("\n");
    83.  
    84. int DS_ok = 0;
    85.  
    86. for(x = 0; x < DS_COUNT; x++) {
    87. string mem_ds = ds18b20_table[x].devID;
    88. for(y = 0; y < 5; y++) {
    89. if(mem_ds == DS_client[y]) {
    90. printf("DS ok\n");
    91. DS_ok++;
    92. }
    93. }
    94. }
    95.  
    96. printf("\n");
    97. if(DS_ok != DS_COUNT) {
    98. printf("DS unknow!\n");
    99. } else {
    100. printf("DS checking OK!\n");
    101. }
    102. printf("\n\n");
    103. }
    104.  
    105.  
    106. int DS18b20::DS_get_num_devices()
    107. {
    108. return this->DS_COUNT;
    109. }
    110.  
    111. void DS18b20::DS_FindDevices()
    112. {
    113. memset(ds18b20_table,0,sizeof(ds18b20_table));
    114.  
    115. DIR *dir;
    116. struct dirent *dirent;
    117. char path[] = "/sys/bus/w1/devices";
    118. int8_t i = 0;
    119. dir = opendir(path);
    120. if (dir != NULL) {
    121. while ((dirent = readdir(dir))) {
    122. if (dirent->d_type == DT_LNK && strstr(dirent->d_name, "28-") != NULL) {
    123. strcpy(ds18b20_table[i].devID, dirent->d_name);
    124. sprintf(ds18b20_table[i].devPath, "%s/%s/w1_slave", path, ds18b20_table[i].devID);
    125. i++;
    126. this->DS_COUNT = i;
    127. //usleep(500000);
    128. }
    129. }
    130. (void) closedir(dir);
    131. } else {
    132. perror("Couldn't open the w1 devices directory");
    133. return;
    134. }
    135. return;
    136. }
    137.  
    138. void DS18b20::lectureTemperatures()
    139. {
    140. if (time(NULL) - departLectureSondes >= tempoLectureSondes) {
    141.  
    142. DS_GetTemp(0,&tempEcIntLue);
    143. DS_GetTemp(1,&tempUnitExtLue);
    144. DS_GetTemp(2,&tempEcExtLue);
    145. DS_GetTemp(3,&tempUnitIntLue);
    146. DS_GetTemp(4,&tempExtLue);
    147.  
    148. qDebug() << "Temperature Exterieur : " << tempExtLue;
    149. qDebug() << "Temperature Unite Exterieur : " << tempUnitExtLue;
    150. qDebug() << "Temperature Echangeur Exterieur : " << tempEcExtLue;
    151. qDebug() << "Temperature Unite Interieur : " << tempUnitIntLue;
    152. qDebug() << "Temperature Echangeur Interieur : " << tempEcIntLue;
    153.  
    154. m_sondesParametres ->temperatureExt = tempExtLue;
    155. m_sondesParametres ->ecritTempExtLue();
    156. m_sondesParametres ->consigneIntCa = tempExtLue - 6;
    157. consIntCa = m_sondesParametres ->consigneIntCa = tempExtLue - 6;
    158. m_sondesParametres ->ecritConsigneIntCa();
    159. m_sondesParametres ->consigneVentIntCa = consIntCa + 2;
    160. m_sondesParametres ->ecritConsigneVentIntCa();
    161. m_sondesParametres ->temperatureUnitExt = tempUnitExtLue;
    162. m_sondesParametres ->ecritTempUnitExtLue();
    163. m_sondesParametres ->temperatureEcExt = tempEcExtLue;
    164. m_sondesParametres ->ecritTempEcExtLue();
    165. m_sondesParametres ->temperatureUnitInt = tempUnitIntLue;
    166. m_sondesParametres ->ecritTempUnitIntLue();
    167. m_sondesParametres ->temperatureEcInt = tempEcIntLue;
    168. m_sondesParametres ->ecritTempEcIntLue();
    169.  
    170. departLectureSondes = time(NULL);
    171. }
    172. }
    To copy to clipboard, switch view to plain text mode 


    and I write my temperature reading in a file where I have my instructions

    parameter file

    Qt Code:
    1. #ifndef PARAMETRES_H
    2. #define PARAMETRES_H
    3. #include <QtWidgets>
    4.  
    5. class Parametres: public QSettings
    6. {
    7. Q_OBJECT
    8.  
    9. public:
    10. Parametres(const QString &nomDuFichier, QSettings::Format format);
    11.  
    12. unsigned long long chronoFiltre;
    13.  
    14. double temperatureExt;
    15. double temperatureUnitExt;
    16. double temperatureEcExt;
    17. double temperatureUnitInt;
    18. double temperatureEcInt;
    19.  
    20. double consigneIntCa;
    21. double consigneVentIntCa;
    22.  
    23. double consigneEteHiver;
    24. double consigneCanicule;
    25. double consigneBlocChauf;
    26. double consigneModeDegCh;
    27. double consigneGrVitExtCh;
    28. double consigneGrVitExtFr;
    29. double consignePeVitIntCh;
    30. double consigneFinDegCh;
    31. double consigneDepartChauffageEnChauffage;
    32. double consigneDepartFroidEnChauffage;
    33. double consignePeVitIntFr;
    34. double consigneDepartFroidEnFroid;
    35. double consigneDepartChauffageEnFroid;
    36. double consigneDepartVentIntCh;
    37. double consigneDegFr;
    38. double consigneFinDegFr;
    39.  
    40. void controleFichier();
    41.  
    42. void ecritTempExtLue();
    43. void ecritTempUnitExtLue();
    44. void ecritTempEcExtLue();
    45. void ecritTempUnitIntLue();
    46. void ecritTempEcIntLue();
    47.  
    48. void ecritChronoFiltre();
    49.  
    50. void ecritConsigneIntCa();
    51. void ecritConsigneVentIntCa();
    52.  
    53. void ecritConsigneEteHiver();
    54. void ecritConsigneGrVitExtCh();
    55. void ecritConsigneGrVitExtFr();
    56. void ecritConsigneCanicule();
    57. void ecritConsigneBlocCh();
    58. void ecritConsigneModeDegCh();
    59. void ecritConsigneFinDegCh();
    60. void ecritConsigneDepartChauffageEnChauffage();
    61. void ecritConsigneDepartFroidEnChauffage();
    62. void ecritConsignePeVitIntCh();
    63. void ecritConsignePeVitIntFr();
    64. void ecritConsigneDepartFroidEnFroid();
    65. void ecritConsigneDepartChauffageEnFroid();
    66. void ecritConsigneDepartVentIntCh();
    67. void ecritConsigneDegFr();
    68. void ecritConsigneFinDegFr();
    69.  
    70. void lireTemperatures();
    71. void lireConsignesGainable();
    72. void lireChronoFiltre();
    73.  
    74. void lireConsigneIntCa();
    75. void lireConsigneVentIntCa();
    76.  
    77. private:
    78. unsigned long long chronoFiltreDefaut = 0;
    79.  
    80. double consigneEteHiverDefaut = 13.5;
    81. double consigneCaniculeDefaut = 30.0;
    82. double consigneBlocChaufDefaut = 11.0;
    83. double consigneModeDegChDefaut = 5.0;
    84. double consigneGrVitExtChDefaut = 5.0;
    85. double consigneGrVitExtFrDefaut = 20.0;
    86. double consigneFinDegChDefaut = 12.5;
    87. double consigneDepartChauffageEnChauffageDefaut = 21.0;
    88. double consigneDepartFroidEnChauffageDefaut = 23.0;
    89. double consignePeVitIntChDefaut = 22.5;
    90. double consigneDepartFroidEnFroidDefaut = 23.0;
    91. double consigneDepartChauffageEnFroidDefaut = 18.0;
    92. double consignePeVitIntFrDefaut = 22.5;
    93. double consigneDepartVentIntChDefaut = 35.0;
    94. double consigneDegFrDefaut = -3.0;
    95. double consigneFinDegFrDefaut = 15.0;
    96.  
    97. void chronoNettoyageFiltreDefaut();
    98.  
    99. void consignesGainableDefaut();
    100. };
    101.  
    102. #endif // PARAMETRES_H
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. #include "parametres.h"
    2.  
    3. Parametres::Parametres(const QString &nomDuFichier, QSettings::Format format): QSettings(nomDuFichier, format)
    4. {
    5.  
    6. }
    7.  
    8. void Parametres::ecritTempExtLue()
    9. {
    10. this ->beginGroup("Temperatures");
    11. this ->setValue("TemperatureExterieurLue", temperatureExt);
    12. this ->endGroup();
    13. }
    14. void Parametres::ecritTempUnitExtLue()
    15. {
    16. this ->beginGroup("Temperatures");
    17. this ->setValue("TemperatureUniteExterieurLue", temperatureUnitExt);
    18. this ->endGroup();
    19. }
    20. void Parametres::ecritTempEcExtLue()
    21. {
    22. this ->beginGroup("Temperatures");
    23. this ->setValue("TemperatureEchangeurExterieurLue", temperatureEcExt);
    24. this ->endGroup();
    25. }
    26. void Parametres::ecritTempUnitIntLue()
    27. {
    28. this ->beginGroup("Temperatures");
    29. this ->setValue("TemperatureUniteInterieurLue", temperatureUnitInt);
    30. this ->endGroup();
    31. }
    32. void Parametres::ecritTempEcIntLue()
    33. {
    34. this ->beginGroup("Temperatures");
    35. this ->setValue("TemperatureEchangeurInterieurLue", temperatureEcInt);
    36. this ->endGroup();
    37. }
    38.  
    39. void Parametres::chronoNettoyageFiltreDefaut()
    40. {
    41. this ->beginGroup("Chrono");
    42. this ->setValue("ChronoNettoyageFiltre",chronoFiltreDefaut);
    43. this ->endGroup();
    44. }
    45.  
    46. void Parametres::consignesGainableDefaut()
    47. {
    48. this ->beginGroup("Consignes");
    49. this ->setValue("ConsigneEteHiver", consigneEteHiverDefaut);
    50. this ->setValue("ConsigneCanicule", consigneCaniculeDefaut);
    51. this ->setValue("ConsigneBlocageChauffage", consigneBlocChaufDefaut);
    52. this ->setValue("ConsigneModeDegivrageChauffage", consigneModeDegChDefaut);
    53. this ->setValue("ConsigneGrandeVitesseExterieurChauffage", consigneGrVitExtChDefaut);
    54. this ->setValue("ConsigneGrandeVitesseExterieurFroid", consigneGrVitExtFrDefaut);
    55. this ->setValue("ConsigneFinDegivrageChauffage", consigneFinDegChDefaut);
    56. this ->setValue("ConsigneDepartChauffageEnModeChauffage", consigneDepartChauffageEnChauffageDefaut);
    57. this ->setValue("ConsigneDepartFroidEnModeChauffage", consigneDepartFroidEnChauffageDefaut);
    58. this ->setValue("ConsignePetiteVitesseInterieurChauffage", consignePeVitIntChDefaut);
    59. this ->setValue("ConsigneDepartFroidEnModeFroid", consigneDepartFroidEnFroidDefaut);
    60. this ->setValue("ConsigneDepartChauffageEnModeFroid", consigneDepartChauffageEnFroidDefaut);
    61. this ->setValue("ConsignePetiteVitesseInterieurFroid", consignePeVitIntFrDefaut);
    62. this ->setValue("ConsigneDepartVentilateurInterieurChauffage", consigneDepartVentIntChDefaut);
    63. this ->setValue("ConsigneDegivrageFroid", consigneDegFrDefaut);
    64. this ->setValue("ConsigneFinDegivrageFroid", consigneFinDegFrDefaut);
    65. this ->endGroup();
    66. }
    67.  
    68. void Parametres::controleFichier()
    69. {
    70. if (this ->childGroups().contains("Consignes") && this ->childGroups().contains("Chrono")) {
    71. qDebug() << "Fichier Parametres OK";
    72. } else {
    73. qDebug() << "Creation Fichier Parametres DEFAUT ";
    74. consignesGainableDefaut();
    75. chronoNettoyageFiltreDefaut();
    76. }
    77. }
    78.  
    79. void Parametres::ecritChronoFiltre()
    80. {
    81. this ->beginGroup("Chrono");
    82. this ->setValue("ChronoNettoyageFiltre",chronoFiltre);
    83. this ->endGroup();
    84. }
    85.  
    86. void Parametres::ecritConsigneIntCa()
    87. {
    88. this ->beginGroup("Consignes");
    89. this ->setValue("ConsigneInterieurCanicule", consigneIntCa);
    90. this ->endGroup();
    91. }
    92.  
    93. void Parametres::ecritConsigneVentIntCa()
    94. {
    95. this ->beginGroup("Consignes");
    96. this ->setValue("ConsigneVentilationInterieurCanicule", consigneVentIntCa);
    97. this ->endGroup();
    98. }
    99.  
    100. void Parametres::ecritConsigneEteHiver()
    101. {
    102. this ->beginGroup("Consignes");
    103. this ->setValue("ConsigneEteHiver", consigneEteHiver);
    104. this ->endGroup();
    105. }
    106.  
    107. void Parametres::ecritConsigneCanicule()
    108. {
    109. this ->beginGroup("Consignes");
    110. this ->setValue("ConsigneCanicule", consigneCanicule);
    111. this ->endGroup();
    112. }
    113.  
    114. void Parametres::ecritConsigneBlocCh()
    115. {
    116. this ->beginGroup("Consignes");
    117. this ->setValue("ConsigneBlocageChauffage", consigneBlocChauf);
    118. this ->endGroup();
    119. }
    120.  
    121. void Parametres::ecritConsigneModeDegCh()
    122. {
    123. this ->beginGroup("Consignes");
    124. this ->setValue("ConsigneModeDegivrageChauffage", consigneModeDegCh);
    125. this ->endGroup();
    126. }
    127.  
    128. void Parametres::ecritConsigneGrVitExtCh()
    129. {
    130. this ->beginGroup("Consignes");
    131. this ->setValue("ConsigneGrandeVitesseExterieurChauffage", consigneGrVitExtCh);
    132. this ->endGroup();
    133. }
    134.  
    135. void Parametres::ecritConsigneGrVitExtFr()
    136. {
    137. this ->beginGroup("Consignes");
    138. this ->setValue("ConsigneGrandeVitesseExterieurFroid", consigneGrVitExtFr);
    139. this ->endGroup();
    140. }
    141.  
    142. void Parametres::ecritConsigneFinDegCh()
    143. {
    144. this ->beginGroup("Consignes");
    145. this ->setValue("ConsigneFinDegivrageChauffage", consigneFinDegCh);
    146. this ->endGroup();
    147. }
    148.  
    149. void Parametres::ecritConsigneDepartChauffageEnChauffage()
    150. {
    151. this ->beginGroup("Consignes");
    152. this ->setValue("ConsigneDepartChauffageEnModeChauffage", consigneDepartChauffageEnChauffage);
    153. this ->endGroup();
    154. }
    155.  
    156. void Parametres::ecritConsigneDepartFroidEnChauffage()
    157. {
    158. this ->beginGroup("Consignes");
    159. this ->setValue("ConsigneDepartFroidEnModeChauffage", consigneDepartFroidEnChauffage);
    160. this ->endGroup();
    161. }
    162.  
    163. void Parametres::ecritConsignePeVitIntCh()
    164. {
    165. this ->beginGroup("Consignes");
    166. this ->setValue("ConsignePetiteVitesseInterieurChauffage", consignePeVitIntCh);
    167. this ->endGroup();
    168. }
    169.  
    170. void Parametres::ecritConsigneDepartFroidEnFroid()
    171. {
    172. this ->beginGroup("Consignes");
    173. this ->setValue("ConsigneDepartFroidEnModeFroid", consigneDepartFroidEnFroid);
    174. this ->endGroup();
    175. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. void Parametres::ecritConsigneDepartChauffageEnFroid()
    2. {
    3. this ->beginGroup("Consignes");
    4. this ->setValue("ConsigneDepartChauffageEnModeFroid", consigneDepartChauffageEnFroid);
    5. this ->endGroup();
    6. }
    7.  
    8. void Parametres::ecritConsignePeVitIntFr()
    9. {
    10. this ->beginGroup("Consignes");
    11. this ->setValue("ConsignePetiteVitesseInterieurFroid", consignePeVitIntFr);
    12. this ->endGroup();
    13. }
    14. void Parametres::ecritConsigneDepartVentIntCh()
    15. {
    16. this ->beginGroup("Consignes");
    17. this ->setValue("ConsigneDepartVentilateurInterieurChauffage", consigneDepartVentIntCh);
    18. this ->endGroup();
    19. }
    20.  
    21. void Parametres::ecritConsigneDegFr()
    22. {
    23. this ->beginGroup("Consignes");
    24. this ->setValue("ConsigneDegivrageFroid", consigneDegFr);
    25. this ->endGroup();
    26. }
    27.  
    28. void Parametres::ecritConsigneFinDegFr()
    29. {
    30. this ->beginGroup("Consignes");
    31. this ->setValue("ConsigneFinDegivrageFroid", consigneFinDegFr);
    32. this ->endGroup();
    33. }
    34.  
    35. void Parametres::lireTemperatures()
    36. {
    37. this ->beginGroup("Temperatures");
    38. temperatureExt = this ->value("TemperatureExterieurLue").toDouble();
    39. temperatureUnitExt = this ->value("TemperatureUniteExterieurLue").toDouble();
    40. temperatureEcExt = this ->value("TemperatureEchangeurExterieurLue").toDouble();
    41. temperatureUnitInt = this ->value("TemperatureUniteInterieurLue").toDouble();
    42. temperatureEcInt = this ->value("TemperatureEchangeurInterieurLue").toDouble();
    43. this ->endGroup();
    44. }
    45.  
    46. void Parametres::lireChronoFiltre()
    47. {
    48. this ->beginGroup("Chrono");
    49. chronoFiltre = this ->value("ChronoNettoyageFiltre",chronoFiltre).toLongLong();
    50. this ->endGroup();
    51. }
    52.  
    53. void Parametres::lireConsignesGainable() // lire consignes
    54. {
    55. this ->beginGroup("Consignes");
    56. consigneEteHiver = this ->value("ConsigneEteHiver").toDouble();
    57. consigneCanicule = this ->value("ConsigneCanicule").toDouble();
    58. consigneBlocChauf = this ->value("ConsigneBlocageChauffage").toDouble();
    59. consigneModeDegCh = this ->value("ConsigneModeDegivrageChauffage").toDouble();
    60. consigneGrVitExtCh = this ->value("ConsigneGrandeVitesseExterieurChauffage").toDouble();
    61. consigneGrVitExtFr = this ->value("ConsigneGrandeVitesseExterieurFroid").toDouble();
    62. consigneFinDegCh = this ->value("ConsigneFinDegivrageChauffage").toDouble();
    63. consigneDepartChauffageEnChauffage = this ->value("ConsigneDepartChauffageEnModeChauffage").toDouble();
    64. consigneDepartFroidEnChauffage = this ->value("ConsigneDepartFroidEnModeChauffage").toDouble();
    65. consignePeVitIntCh = this ->value("ConsignePetiteVitesseInterieurChauffage").toDouble();
    66. consigneDepartFroidEnFroid = this ->value("ConsigneDepartFroidEnModeFroid").toDouble();
    67. consigneDepartChauffageEnFroid = this ->value("ConsigneDepartChauffageEnModeFroid").toDouble();
    68. consignePeVitIntFr = this ->value("ConsignePetiteVitesseInterieurFroid").toDouble();
    69. consigneDepartVentIntCh = this ->value("ConsigneDepartVentilateurInterieurChauffage").toDouble();
    70. consigneDegFr = this ->value("ConsigneDegivrageFroid").toDouble();
    71. consigneFinDegFr = this ->value("ConsigneFinDegivrageFroid").toDouble();
    72. consigneIntCa = this ->value("ConsigneInterieurCanicule").toDouble();
    73. consigneVentIntCa = this ->value("ConsigneVentilationInterieurCanicule").toDouble();
    74. this ->endGroup();
    75. }
    To copy to clipboard, switch view to plain text mode 


    Added after 4 minutes:


    how do we proceed with the QlcNumber??
    given that it doesn't have bools?? THANKS
    Last edited by ludoQtCreator; 6th February 2025 at 18:06.

  3. #23
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,539
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QLabel QPixmap change

    Quote Originally Posted by ludoQtCreator View Post
    I noticed that my gifs move in slow motion except during the reading of my probes
    Quickly.
    In the main thread (GUI) you should define the slot temperatureChanged(int new_temperature).
    In this slot you display the appropriate graphics.
    In the additional thread you make a method started by QTimer which sends the signal newTemperature(int) to the slot temperatureChanged(int new_temperature) only when the currently read value is different from the previous one.
    Do not create a new class derived from QThread.
    I recommend an article on how to use QThread correctly.

  4. #24
    Join Date
    Jan 2025
    Posts
    14
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QLabel QPixmap change

    Do you have an example? Please .
    because I can't! THANKS

  5. #25
    Join Date
    Jan 2025
    Posts
    14
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QLabel QPixmap change

    so I succeeded:

    Qt Code:
    1. class MainWindow: public QWidget
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. MainWindow(QWidget *parent = nullptr);
    7. public slots:
    8. void changeTemperatures(int m_temperatures);
    9. private:
    10. QLCDNumber *m_tempExtLue;
    11. QLCDNumber *m_tempUnitExtLue;
    12. QLCDNumber *m_tempEcExtLue;
    13. QLCDNumber *m_tempUnitIntLue;
    14. QLCDNumber *m_tempEcIntLue;
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. #include "mainwindow.h"
    2.  
    3. MainWindow::MainWindow(QWidget *parent)
    4. :QWidget (parent)
    5. {
    6. m_disp1 = new QGroupBox("Temp°C Ext",m_window);
    7. m_disp1 ->setStyleSheet("QGroupBox:title {color: orangered;}");
    8. m_disp1 ->setFont(QFont("Times", 18, QFont::Bold));
    9. m_disp1 ->setGeometry(200,40,240,120);
    10. m_tempExtLue = new QLCDNumber(m_disp1);
    11. m_tempExtLue ->setGeometry(0,35,240,80);
    12.  
    13. m_disp2 = new QGroupBox("Temp°C UnitExt",m_window);
    14. m_disp2 ->setStyleSheet("QGroupBox:title {color: orangered;}");
    15. m_disp2 ->setFont(QFont("Times", 18, QFont::Bold));
    16. m_disp2 ->setGeometry(520,40,240,120);
    17. m_tempUnitExtLue = new QLCDNumber(m_disp2);
    18. m_tempUnitExtLue ->setGeometry(0,35,240,80);
    19.  
    20. m_disp3 = new QGroupBox("Temp°C EcUnitExt",m_window);
    21. m_disp3 ->setStyleSheet("QGroupBox:title {color: orangered;}");
    22. m_disp3 ->setFont(QFont("Times", 18, QFont::Bold));
    23. m_disp3 ->setGeometry(840,40,240,120);
    24. m_tempEcExtLue = new QLCDNumber(m_disp3);
    25. m_tempEcExtLue ->setGeometry(0,35,240,80);
    26.  
    27. m_disp4 = new QGroupBox("Temp°C UnitInt",m_window);
    28. m_disp4 ->setStyleSheet("QGroupBox:title {color: orangered;}");
    29. m_disp4 ->setFont(QFont("Times", 18, QFont::Bold));
    30. m_disp4 ->setGeometry(1160,40,240,120);
    31. m_tempUnitIntLue = new QLCDNumber(m_disp4);
    32. m_tempUnitIntLue ->setGeometry(0,35,240,80);
    33.  
    34. m_disp5 = new QGroupBox("Temp°C EcUnitInt",m_window);
    35. m_disp5 ->setStyleSheet("QGroupBox:title {color: orangered;}");
    36. m_disp5 ->setFont(QFont("Times", 18, QFont::Bold));
    37. m_disp5 ->setGeometry(1480,40,240,120);
    38. m_tempEcIntLue = new QLCDNumber(m_disp5);
    39. m_tempEcIntLue ->setGeometry(0,35,240,80);
    40.  
    41. connect(&m_mainwindowThread, &Thread::majTemperatures, this, &MainWindow::changeTemperatures);
    42. changeTemperatures(1);
    43. m_window->show();
    44. }
    45.  
    46. void MainWindow::changeTemperatures(int m_temperatures)
    47. {
    48. switch (m_temperatures) {
    49.  
    50. case 0:
    51.  
    52. qDebug() << "lecture Temperatures";
    53.  
    54. m_mainwindowParametres ->lireTemperatures();
    55.  
    56. m_tempExtLue ->display(m_mainwindowParametres ->temperatureExt);
    57. m_tempUnitExtLue ->display(m_mainwindowParametres ->temperatureUnitExt);
    58. m_tempEcExtLue ->display(m_mainwindowParametres ->temperatureEcExt);
    59. m_tempUnitIntLue ->display(m_mainwindowParametres ->temperatureUnitInt);
    60. m_tempEcIntLue ->display(m_mainwindowParametres ->temperatureEcInt);
    61.  
    62. break;
    63.  
    64. default:
    65.  
    66. qDebug() << "fin de lecture Temperatures";
    67.  
    68. break;
    69. }
    70. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. class Thread: public QThread
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. Thread();
    7.  
    8. QTimer *m_timer1;
    9.  
    10. int m_timerTemps = 5000;
    11.  
    12. void lectureSondes();
    13. signals:
    14. void majTemperatures(int m_temperatures);
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. #include "thread.h"
    2.  
    3. Thread::Thread()
    4. {
    5. qDebug() << "Thread";
    6.  
    7. m_timer1 = new QTimer(this);
    8. m_timer1 ->start(m_timerTemps);
    9. connect(m_timer1, &QTimer::timeout, this, &Thread::lectureSondes);
    10. }
    11.  
    12. void Thread::lectureSondes()
    13. {
    14. emit majTemperatures(0);
    15. }
    To copy to clipboard, switch view to plain text mode 

  6. #26
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,287
    Thanks
    310
    Thanked 868 Times in 855 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QLabel QPixmap change

    Qt Code:
    1. void Thread::lectureSondes()
    2. {
    3. int newTemperature = readTemperature();
    4. if ( newTemperature != oldTemperature )
    5. {
    6. oldTemperature = newTemperature;
    7. emit majTemperatures( newTemperature );
    8. }
    9. }
    To copy to clipboard, switch view to plain text mode 
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  7. #27
    Join Date
    Jan 2025
    Posts
    14
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QLabel QPixmap change

    in fact I want to read my probes that I write to a file every 5 seconds, and then I read this file wherever I need temperatures in my code.
    and on the GUI I read this file every 5 seconds to update the QlCDNumbers


    Added after 30 minutes:


    my gifs always run in slow motion
    Last edited by ludoQtCreator; 7th February 2025 at 19:00.

Similar Threads

  1. QLabel does not repaint QPixmap
    By __Emanuel in forum Newbie
    Replies: 7
    Last Post: 11th February 2017, 16:18
  2. Replies: 3
    Last Post: 10th April 2011, 16:55
  3. DrawLine over QPixmap within Qlabel
    By Qt Coder in forum Qt Programming
    Replies: 8
    Last Post: 26th March 2009, 13:21
  4. Replies: 2
    Last Post: 20th January 2009, 08:13
  5. Replies: 1
    Last Post: 2nd August 2008, 16:46

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.