Difference between revisions of "CSC220 QtCreator Process Slot"

From dftwiki3
Jump to: navigation, search
(Created page with '--~~~~ ---- * Partial solution for question of the C++ Qt crash course <code><pre> void MainWindow::processSlot() { QString kml = ui->textBr…')
 
Line 2: Line 2:
 
----
 
----
  
* Partial solution for question of the [[CSC220 C++Qt Crash Course | C++ Qt crash course]]
+
<br />
 +
== Partial solution for question of the [[CSC220 C++Qt Crash Course | C++ Qt crash course]]==
 
<code><pre>
 
<code><pre>
  

Revision as of 17:39, 5 December 2010

--D. Thiebaut 22:39, 5 December 2010 (UTC)



Partial solution for question of the C++ Qt crash course


void MainWindow::processSlot() {
    QString kml = ui->textBrowser->toPlainText();
    QStringList lines = kml.split( "\n" );
    ui->textBrowser->clear();
    for ( int i = 0; i < lines.size(); i++ ) {
        QString line = lines[i];
        if ( line.indexOf( "<gx:coord>" ) != -1 ) {
            //ui->textBrowser->append( QString( "%1: %2").arg( i ).arg( lines[i] ));
            QStringList words = line.split( "gx:coord>" );
            ui->textBrowser->append( QString( "%1").arg( words[1].replace( "</", "" ) ) );
        }
    }
}