Bonjour,
je vous contact car je me heurte a un souci dans la programmation de ma fonction/logiciel.

Le projet : reussir a faire un genre de calculette avec 4 cases pour calculer un pourcentage.

Une image vaut mieux que mille mots :



Ce que je souhaite c'est que l'utilisateur puisse saisir les informations dans les cases 1, 2 et 4 (Valeur intermediaire, total, 100) et qu'en cliquant sur Calculer le resultat apparaisse.

Exemple : J'ai lu 400 pages sur un livre qui en compte 800 je fais donc (400x100)/800 ce qui devrait afficher 50 ^^

Voici les differents partie de code que jai pu faire :

pourcent-calc.pro
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
#-------------------------------------------------
#
# Project created by QtCreator 2017-10-15T02:21:34
#
#-------------------------------------------------
 
QT       += core gui
 
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
 
TARGET = pourcent-calc
TEMPLATE = app
 
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
 
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
 
 
SOURCES += \
        main.cpp \
        mainwindow.cpp
 
HEADERS += \
        mainwindow.h
 
FORMS += \
        mainwindow.ui
mainwindow.h

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
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
 
#include <QMainWindow>
 
using namespace std;
 
namespace Ui {
class MainWindow;
}
 
class MainWindow : public QMainWindow
{
    Q_OBJECT
 
public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
 
private slots:
 
    void on_pushButton_clicked();
 
private:
    Ui::MainWindow *ui;
};
 
#endif // MAINWINDOW_H
main.cpp
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
#include "mainwindow.h"
#include <QApplication>
 
using namespace std;
 
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();
 
    return a.exec();
}
mainwindow.cpp
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
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QApplication>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_pushButton_clicked()
{
    valeurInter = (textEdit)findViewById(R.id.textEditvaleurInter);
    valeurInter = valeurInter.getText().toString();
}
J'ai un gros doute sur la dernière partie en gras...

Pouvez vous m'aider ou me donner un élément de réponse svp ?

Merci et a très vite
mcvovol