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
| void FenPrincipale::ouvrirFichier()
{
QString fichier = QFileDialog::getOpenFileName(this,"Ouvrir",QString(),".../test(*.txt)");
bool valid = QFile::exists(".../test.txt");
QString code;
//if(valid == true)
//{
QString fileName = "fichier.txt";
QFile fichier1(fileName);
fichier1.open(QIODevice::ReadOnly | QIODevice::Text);
QTextStream flux(&fichier);
QString ligne;
while(!flux.atEnd())
{
ligne = flux.readLine(); //traitement de la ligne
QRegularExpressionMatch *match=new QRegularExpressionMatch;
QRegularExpression re("class[ \t]+(?<name>\\w+)([ \t]*:[ \t]*public[ \t]+(?<nameParent>\\w+))?");
QMessageBox::information(this,"",fichier);
if(ligne.contains(re, match))
{
QStringList stringList = ligne.split(" ");
nom->setText(stringList[1]);
//nom->insert(stringList[1]);
this->update();
printf(" Ca a marché !");
//QString className = match.captured("name");
//QString classeMere = match->captured("nameParent");
}
this->update();
} |
Partager