Advertisement
nRikee

Búsqueda en QtJambi

Apr 11th, 2013
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.67 KB | None | 0 0
  1.     // BUSCAR
  2.     public void on_botoBusqueda_clicked(){
  3.         ui.textEdit.setFocus();
  4.        
  5.         String inp = ui.editBusqueda.text();
  6.         String text = ui.textEdit.toPlainText();
  7.  
  8.         if ( ui.textEdit.find(inp) ){
  9.             ui.textEdit.moveCursor(MoveOperation.Start);
  10.             int index = 0;
  11.             int a = 0;
  12.            
  13.             while ( index < inp.length() ){
  14.                 if ( text.charAt(a) == inp.charAt(index) ) 
  15.                         index++;
  16.                 else    index=0;
  17.                 a++;
  18.                 ui.textEdit.moveCursor(MoveOperation.Right);
  19.             }
  20.             ui.textEdit.moveCursor(MoveOperation.PreviousWord);
  21.         } else {
  22.             ui.statusbar.showMessage("No s'han trobat resultats");
  23.         }
  24.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement