Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
2260 connectés 

  FORUM HardWare.fr
  Programmation
  C++

  prob de boite de dialogue

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

prob de boite de dialogue

n°738182
narry
Posté le 25-05-2004 à 17:56:36  profilanswer
 

bonjour à tous , j'ai un prob avec une fenetre de dialogue, donc je doit lalancer a partir d'un menu et je doit la valider avec le bouton OK, sauf que la sauvegarde ne se fait pas, donc je vous donne le code qui concerne le bouton OK et celui du "save project" qui lance la boite de dialogue
 

Code :
  1. void KGenerator::slotSaveProject() {
  2.   // On affiche la boite de dialogue de gestion du projet  
  3.   if (*authorExample == QString::null) {
  4.     QMessageBox::warning(this,"Example","Missing : author example" );
  5.   } else {
  6.     if (*titleExample == QString::null) {
  7.       QMessageBox::warning(this,"Example","Missing : title example" );
  8.     } else {
  9.       if (*urlBookExample == QString::null) {
  10.    QMessageBox::warning(this,"Example","Missing : target example" );
  11.       }
  12.    else{
  13.    dialogueProjet->show(*projectName, *rootUrl, depth, exitAutorized,
  14.               targetOnMaxDepth,*listGoals, *authorExample,
  15.               *titleExample, *urlBookExample, authorDistance,
  16.               titleDistance);
  17.    // Si on a cliquer sur ok  
  18.    if (dialogueProjet->result() == QDialog::Accepted) {
  19.      // On charge les informations du projet  
  20.      *projectName = dialogueProjet->getProjectName();
  21.      *rootUrl = dialogueProjet->getRoot();
  22.      depth = dialogueProjet->getDepth();
  23.      exitAutorized = dialogueProjet->getExitAutorized();
  24.      targetOnMaxDepth = dialogueProjet->getTargetOnMaxDepth();
  25.      *listGoals = dialogueProjet->getListGoals();
  26.      authorDistance = dialogueProjet->getAuthorDistance();
  27.      titleDistance = dialogueProjet->getTitleDistance();
  28.      //cout << "Pas de sauvegarde sur le disque " << endl;  
  29.      saveProjet();
  30.    }
  31.    }
  32.       }
  33.     }
  34.   }
  35.   void KGenerator::saveProjet() {
  36.   ConfigFileGenerator generator;
  37.     // Initialisation des champs  
  38.   // racine du site  
  39.     generator.setWebSiteAddress(rootUrl->latin1());
  40.     // profondeur max des livres dans le site  
  41.     cout<<"l'ancien nbmax"<<depth<<endl;
  42. depth=5;
  43.   generator.setNbMaxClick(depth);
  44. cout<<"le nouveau nbmax"<<depth<<endl;
  45.   // autorisation de sortie du site  
  46.   if(exitAutorized){
  47.     generator.setExitAuthorized();
  48. }
  49.   generator.addTargetOnMaxDepth(targetOnMaxDepth);
  50.   // les cibles  
  51.   int count = listGoals->count();
  52.   int i;
  53.   for(i=0; i<count; i++){
  54.     generator.addGoal(listGoals->operator[](i).latin1());
  55. }
  56.   // URL interdites  
  57.  count = forbiddenLinkList->count();
  58.   for(i=0; i<count ; i++){
  59.     generator.addForbiddenUrl(forbiddenLinkList->text(i).latin1());
  60. }
  61.   // noms de lien interdits  
  62.   count = forbiddenLinkNameList->count();
  63.   for(i=0; i<count; i++){
  64.     generator.addForbiddenLinkName(forbiddenLinkNameList->text(i).latin1());
  65. }
  66.   // noms de lien à traverser  
  67.   count = expectedLinkNameList->count();
  68.   cout <<count<<endl;
  69.   for(i=0; i<count; i++){
  70.     generator.addExpectedLinkName(expectedLinkNameList->text(i).latin1());
  71. }
  72.   //Exemple  
  73.   if (titleExampleStart.y() < authorExampleStart.y()) {
  74.     generator.defineTitleBeforeAuthor(true);
  75.   } else {
  76.     if ((titleExampleStart.y() == authorExampleStart.y()) &&
  77.    (titleExampleStart.x() < authorExampleStart.x())) {
  78.       generator.defineTitleBeforeAuthor(true);
  79.     } else {
  80.       generator.defineTitleBeforeAuthor(false);
  81.     }
  82.   }
  83.   //exemple : auteur  
  84.   generator.addAuthorExample(qstringFilter(*authorExample));
  85.   generator.addAuthorUrlExample(authorUrlExample->latin1());
  86.   generator.addAuthorExampleDistance(authorDistance);
  87.   //exemple : titre livre  
  88.   generator.addTitleExample(qstringFilter(*titleExample));
  89.   generator.addTitleUrlExample(titleUrlExample->latin1());
  90.   generator.addTitleExampleDistance(authorDistance);
  91.   //exemple : cible  
  92.   generator.addUrlBookExample(urlBookExample->latin1());
  93.   // vérification des champs et impression dans le fichier  
  94.   try{
  95.    generator.checkConfig();
  96.    string fileName = projectName->latin1();
  97.    fileName += ".cfg";
  98.    generator.printXML(fileName);
  99.    generator.print();
  100.   }
  101.   catch(Exception e){
  102.     cout << "Erreur : " << e.getError() << endl;
  103.     QMessageBox::critical(this,"Error",e.getError().c_str(),0,0,1);
  104.   }
  105.   }


 
et celui du bouton OK

Code :
  1. buttonOk = new KPushButton("Ok",this);
  2.   buttonOk->setGeometry(450,420,80,20);
  3.   buttonOk->show();
  4.   connect(buttonOk, SIGNAL(clicked()), this, SLOT(slotValidate()));
  5. void KProjectDialog::slotValidate() {
  6.  bool intOk = false;
  7.   if (editProjectName->text().length() > 0) {
  8.       if (editRoot->text().length() > 0) {
  9.         editDepth->text().toInt(&intOk);
  10.         if (intOk) {
  11.    if (listGoals->count() > 0) {
  12.      emit signalAccepted();
  13.    } else {
  14.      QMessageBox::critical(this,"Error","You need at least one goal" );
  15.      editGoal->setFocus();
  16.    }
  17.       } else {
  18.    QMessageBox::critical(this,"Error","Error with depth" );
  19.    editDepth->setFocus();
  20.       }
  21.     } else {
  22.       QMessageBox::critical(this,"Error","You need a root" );
  23.       editRoot->setFocus();
  24.     }
  25.   } else {
  26.     QMessageBox::critical(this,"Error","You need a project name" );
  27.     editProjectName->setFocus();
  28.   }
  29. }


vous pourriez peut etre comme ça a vue d'oeil me dire où ça se pourrais que ça cloche parce que moi je ne vois pas du tout  :fou:

mood
Publicité
Posté le 25-05-2004 à 17:56:36  profilanswer
 

n°742806
narry
Posté le 28-05-2004 à 11:11:46  profilanswer
 

alors je reformule ma phrase, y aurait il qlq 1 pour m'expliquer comment fait on pour programmer une boite de dialogue pour l'option enregistrement d'un fichier


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  C++

  prob de boite de dialogue

 

Sujets relatifs
prob de transfert sur socket TCP[java] ouverture d'une boite de dialogue
Heritage+boite dialogueboite de dialogue vba excel
probleme d'affichage d'une boite de dialogue avec JOptionPaneProb avec deux DIV
[access/vba] boite de dialogue avec des boutons radio à l'intérieururgent, prob pour boite de dialogue
Plus de sujets relatifs à : prob de boite de dialogue


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR