Bonsoir,
Je vous explique brièvement ce que je cherche à faire :
J'ai un widget qui doit afficher un chrono mis à jour très fréquemment, dont voici le code :
J'ai mis la première fonction dans un run(), sachant que ma classe hérite de QThread pour pouvoir s'exécuter en même temps que le reste de l'appli.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 void countdown::run() { long cpt=0; while(cpt<1000000){ QTimer *t = new QTimer(); t->start(10); connect(t, SIGNAL(timeout()), this, SLOT(maj())); cpt++; } } void countdown::maj() { long diff; datetime dateNow; diff = *dateC-dateNow; if(diffsec<0) diffsec=99; QString tmp; if(diffsec<10) tmp= "0" + QString::number(diffsec); else tmp = QString::number(diffsec); ui->ctdwn->setText(QString::number(diff)+"."+tmp); diffsec=diffsec-1; }
Application composée aussi d'un mainwindow sur lequel j'affiche le widget.
Sauf que j'ai une erreur que voici :
Sinon j'ai testé sans thread, mais le compteur n'était pas mis à jour.....\affimage\countdown.cpp:26: error: reference to 'connect' is ambiguous
..\..\Desktop\Qt\4.7.4\mingw\include/QtCore/qobject.h:313: error: candidates are: bool QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const
..\..\Desktop\Qt\4.7.4\mingw\include/QtCore/qobject.h:198: error: candidates are: static bool QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)
..\..\Desktop\Qt\4.7.4\mingw\include/QtCore/qobject.h:313: error: bool QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const
..\..\Desktop\Qt\4.7.4\mingw\include/QtCore/qobject.h:198: error: static bool QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)
Merci de votre aide !
Partager