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();
} |
Partager