Difference between revisions of "CSC220 QtCreator Process Slot"
(Created page with '--~~~~ ---- * Partial solution for question of the C++ Qt crash course <code><pre> void MainWindow::processSlot() { QString kml = ui->textBr…') |
(→Partial solution for question of the C++ Qt crash course) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
---- | ---- | ||
− | + | <br /> | |
− | < | + | == Partial solution for question of the [[CSC220 C++Qt Crash Course | C++ Qt crash course]]== |
+ | <br /> | ||
+ | <source lang="cpp"> | ||
void MainWindow::processSlot() { | void MainWindow::processSlot() { | ||
Line 11: | Line 13: | ||
for ( int i = 0; i < lines.size(); i++ ) { | for ( int i = 0; i < lines.size(); i++ ) { | ||
QString line = lines[i]; | QString line = lines[i]; | ||
− | if ( line. | + | if ( line.contains( "<gx:coord>" ) ) { |
//ui->textBrowser->append( QString( "%1: %2").arg( i ).arg( lines[i] )); | //ui->textBrowser->append( QString( "%1: %2").arg( i ).arg( lines[i] )); | ||
− | + | line.remove( "<gx:coord>" ); | |
− | ui->textBrowser->append( | + | line.remove( "</gx:coord>" ); |
+ | ui->textBrowser->append( line ); | ||
} | } | ||
} | } | ||
} | } | ||
− | </ | + | </source> |
<br /> | <br /> |
Latest revision as of 12:24, 6 February 2014
--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.contains( "<gx:coord>" ) ) {
//ui->textBrowser->append( QString( "%1: %2").arg( i ).arg( lines[i] ));
line.remove( "<gx:coord>" );
line.remove( "</gx:coord>" );
ui->textBrowser->append( line );
}
}
}