void MainWindow::on_pbGetGPSData_clicked() { int iSatellitesUsed = 0; double Longitude = 0; gpsmm gps_rec("localhost", "2947"); if (gps_rec.stream(WATCH_ENABLE|WATCH_JSON) == NULL) { cerr << "No GPSD running.\n"; } // Infinite loop for (;;) { struct gps_data_t* newdata; if (!gps_rec.waiting(5000000)) // if no new data then skip next block and come back here continue; if ((newdata = gps_rec.read()) == NULL) //else there is new data, but check its not Null { ui->leGPSstatus->setText("Read Error"); } else // if not Null then printoutresults { iSatellitesUsed = newdata->satellites_used; Longitude = newdata->fix.longitude; if(iSatellitesUsed>0) goto updateGPSdata; } } // infinite loop end updateGPSdata: int test=0; ui->leGPS->setText(QString::number(iSatellitesUsed)); ui->leGPSlongitude->setText(QString::number(Longitude)); }