Salut, j'ai codé une petite fenêtre qui affiche une ligne toute les 100 ms aafin de former un signe "+". Quand je compile tout ce passe impec, mais rien ne se passe, voici le code :

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
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
 
#include "MainWindow.h"
#include "Mapscene.h"
#include "MapView.h"
 
MainWindow::MainWindow(QWidget* widgetParent) : QWidget(widgetParent)
{
    this->setWindowTitle("Test_Qt");
    this->resize(200, 200);
 
    this->initMapScene();
    this->initMapView();
 
    QHBoxLayout* layout = new QHBoxLayout(this);
        layout->addWidget(vue);
 
    QTimer* timer = new QTimer(this);
        timer->setSingleShot(false);
        timer->setInterval(100);
 
    QObject::connect(timer, SIGNAL(timeout()), this, SLOT(drawWords()));
 
    this->setLayout(layout);
    this->show();
}
 
MainWindow::~MainWindow()
{
 
}
 
bool MainWindow::initMapScene()
{
    scene = new MapScene(this);
        QRectF surfacescene(-25, -25, 50, 50);
        scene->setSceneRect(surfacescene);
        QPointF pointOrigin(0, 0);
        scene->setPointOrigin(pointOrigin);
 
    return true;
}
 
 
bool MainWindow::initMapView()
{
    vue = new MapView(scene, this);
        vue->setFixedSize(50, 50);
        vue->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
        vue->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
 
    return true;
}
 
void MainWindow::drawWords()
{
    static int nbCall = 0;
    if (nbCall = 0)
    {
        QLineF line(0, 0, 0, 10);
        this->drawLine(line);
    }
    else if (nbCall = 1)
    {
        QLineF line(0, 0, -10, 0);
        this->drawLine(line);
    }
    else if (nbCall = 2)
    {
        QLineF line(0, 0, 0, -10);
        this->drawLine(line);
    }
    else if (nbCall = 3)
    {
        QLineF line(0, 0, 10, 0);
        this->drawLine(line);
    }
    else
    {
        QLineF line(0, 0, 0, 10);
        this->drawLine(line);
    }
}
 
void MainWindow::drawLine(QLineF &line)
{
    QPointF linePoint1 = line.p1();
    QPointF linePoint2 = line.p2();
 
    QPointF point1 = scene->pointStandart(linePoint1);
    QPointF point2 = scene->pointStandart(linePoint2);
 
    QLineF line2(point1, point2);
    //QPen pen(Qt::blue, 5, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    scene->addLine(line2);
}
Le compilateur me retourne 4 mises en garde cependant:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
 
MainWindow.cpp: In member function 'void MainWindow::drawWords()':
MainWindow.cpp:56: warning: suggest parentheses around assignment used as truth value
MainWindow.cpp:61: warning: suggest parentheses around assignment used as truth value
MainWindow.cpp:66: warning: suggest parentheses around assignment used as truth value
MainWindow.cpp:71: warning: suggest parentheses around assignment used as truth value
Je crois que c'est au niveau de drawWords() et de drawLine() qui sont tout les deux des slots... Merci pour aide.