Erreur à l'exécution du programme
Bonjour,
Toujours en train de me faire la main sous QT, je suis confronté à un problème que je n'arrive pas à résoudre que je vais essayer de vous présenter au mieux.
J'ai créé 3 librairies dynamiques QT (.so) (IDE netbeans) :
une librairie "Core", une librairie "templates" (qui peut s'appuyer sur Core) et enfin une librairie Gui qui s'appuie sur ces 2 dernières.
Lors de mes tests, je me suis aperçu que mon widget "bandeau_Rouge" (lib templates) me crée une erreur : glic detected *** corrupted double-link
J'ai trouvé le coupable mais je ne comprends absolument pas pourquoi (c'est la variable dureeRafraichissement)
Voici mon code :
bandeaurouge.hpp
Code:
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
|
#include <QTimer>
#include "../../ui_bandeauRouge.h"
class bandeauRouge : public QWidget {
Q_OBJECT
public:
bandeauRouge();
virtual ~bandeauRouge();
private slots :
void onTimeOutDate();
private:
QTimer *timerDate;
int dureeRafraichissement; // Si on commente la ligne plus de plantage
Ui::bandeauRouge widget;
};
#endif /* _BANDEAUROUGE_H */ |
bandeaurouge.cpp:
Code:
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 32 33 34 35 36
|
#include "bandeauRouge.h"
#include <QDebug>
#include <QTime>
#include <QDateTime>
bandeauRouge::bandeauRouge() {
widget.setupUi(this);
timerDate = new QTimer();
//dureeRafraichissement = 60000; // 60s
connect(timerDate, SIGNAL(timeout()),this, SLOT(onTimeOutDate()) );
// (0) permet de lancer le timer immédiatement:
timerDate->start(0);
}
bandeauRouge::~bandeauRouge() {
qDebug() << "destructeur bandeau rouge";
if ( timerDate ) {
delete timerDate;
}
}
void bandeauRouge::onTimeOutDate() {
// ici, on replace l'intervalle à* 1 minute
timerDate->setInterval(60000); // rafraichissement toutes les minutes
widget.lineEdit_date->setText( QDateTime::currentDateTime().toString("dd/MM/yyyy hh:mm") );
} |
bandeaurouge.ui
Code:
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
|
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>bandeauRouge</class>
<widget class="QWidget" name="bandeauRouge">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1024</width>
<height>20</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>1024</width>
<height>20</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>20</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="windowTitle">
<string>bandeauRouge</string>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 0, 0);</string>
</property>
<widget class="QWidget" name="horizontalLayoutWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1021</width>
<height>22</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,0,0,0,0,0,0">
<property name="spacing">
<number>0</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QLineEdit" name="lineEdit_date">
<property name="minimumSize">
<size>
<width>110</width>
<height>20</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>20</height>
</size>
</property>
<property name="baseSize">
<size>
<width>110</width>
<height>20</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>18/07/2012 18:55</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Label1</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_2">
<property name="minimumSize">
<size>
<width>140</width>
<height>20</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string/>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Label2</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_utilisateur">
<property name="minimumSize">
<size>
<width>120</width>
<height>20</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="text">
<string>Label3</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_4">
<property name="minimumSize">
<size>
<width>140</width>
<height>20</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Label4</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_5">
<property name="minimumSize">
<size>
<width>140</width>
<height>20</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui> |
Code de test tout bête (dans la librairie Gui) : classe testUi
Code:
1 2 3
|
BandeauRouge *bandeau = new bandeauRouge();
bandeau->show(); |
Lancement du test : (dans un projet à part, pour tester)
Code:
1 2 3 4 5
|
// testQt.C
QApplication app;
testUi* test = new testUi();
return app.exe; |
Merci d'avance !