QTextBrowser et vérification du nombre de caractères
Bonjour
J'ai initialisé QTextBrowser dans le .h et je n'es instancie dans le .cpp mais il s'affiche pas et je voudrais vérifie le nombre de caractère
Voici mes fichier
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
| #ifndef NIVEAU_2_H
#define NIVEAU_2_H
#include <QMainWindow>
#include <QPushButton>
#include <QMessageBox>
#include <QTextBrowser>
namespace Ui {
class Niveau_2;
}
class Niveau_2 : public QMainWindow
{
Q_OBJECT
public:
explicit Niveau_2(QWidget *parent = 0);
~Niveau_2();
private slots:
void handleButton();
private:
Ui::Niveau_2 *ui;
QPushButton *OK_button;
QPushButton *Annuler_button;
QTextBrowser *txt;
QMessageBox *msgBox;
};
#endif // NIVEAU_2_H |
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
| #include "niveau_2.h"
#include "ui_niveau_2.h"
Niveau_2::Niveau_2(QWidget *parent) :
QMainWindow(parent)
{
// Create the button, make "this" the parent
OK_button = new QPushButton("OK", this);
// set size and location of the button
OK_button->setGeometry(QRect(QPoint(150, 50),
QSize(50, 50)));
Annuler_button = new QPushButton("Annuler",this);
Annuler_button ->setGeometry(QRect(QPoint(10,50),
QSize(50,50)));
txt->;
// Connect button signal to appropriate slot
connect(OK_button, SIGNAL (released()), this, SLOT (handleButton()));
}
void Niveau_2::handleButton()
{
msgBox = new QMessageBox();
msgBox ->setText("Identifiant doit avoir 8 caractères");
msgBox->exec();
}
Niveau_2::~Niveau_2()
{
delete ui;
} |
Code:
1 2 3 4 5 6 7 8 9 10 11 12
| #include "niveau_2.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Niveau_2 w;
w.show();
return a.exec();
} |