Bonsoir,
Je cherche à programmé un petit truc simple. Dans ce cadre, j'ai essayer de renvoyer dans une classe qui contient un int, un int depuis un champ. J'ai essayer avec un forçage, sans passer par le champ. J'obtiens toujours la même erreur. J'aimerais y voir plus clair et résoudre l'erreur si c'st possible.
/home/alexandre/Documents/Programmations/QtProject/Print-Center/Print_center/mainwindow.cpp:-1: In member function 'void MainWindow::calculCout()':
/home/alexandre/Documents/Programmations/QtProject/Print-Center/Print_center/mainwindow.cpp:29: erreur : invalid conversion from 'convHeureVersCent*' to 'int' [-fpermissive]
/home/alexandre/Documents/Programmations/QtProject/Print-Center/Print_center/convheureverscent.h:8: error: initializing argument 1 of 'convHeureVersCent::convHeureVersCent(int)' [-fpermissive]C'est vraiment basique et j'espère compléter après, plus tard.
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
96
97
98
99
100
101
102
103
104
105 #ifndef CONVHEUREVERSCENT_H #define CONVHEUREVERSCENT_H class convHeureVersCent { public: convHeureVersCent(int min_entry); int getCentieme(); private: int m_minutes; }; #endif // CONVHEUREVERSCENT_H #include "convheureverscent.h" /* Constructeur */ convHeureVersCent::convHeureVersCent(int min_entry) { m_minutes = min_entry; //Minutes à convertir } int convHeureVersCent::getCentieme() { int centieme = 0; centieme = m_minutes / 60; return centieme; } #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <convheureverscent.h> namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private: Ui::MainWindow *ui; public slots: void calculCout(); }; #endif // MAINWINDOW_H #include "mainwindow.h" #include "ui_mainwindow.h" #include "convheureverscent.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QObject::connect(ui->buttonCalculer, SIGNAL(clicked()), this, SLOT(calculCout())); } MainWindow::~MainWindow() { delete ui; } void MainWindow::calculCout() { int valChampHeure = ui->champHeures->text().toInt(); int valChampMin = ui->champMinutes->text().toInt(); int centiemeMin = 0; if(valChampMin > 0) { //Initialise la classe convHeureVersCent convCentieneMin = new convHeureVersCent(valChampMin); centiemeMin = convCentieneMin.getCentieme(); } } #include "mainwindow.h" #include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); return a.exec(); }
Merci beaucoup
Partager