bmn
9th December 2010, 12:41
Hello everyone
I'm trying to get a function to call another function from the same class
this is the function i want called:
void MainWindow::locationUpdated(QGeoPositionInfo currentPosition) {
//Defines a geographical position on the surface of the Earth
QGeoCoordinate geoCoordinate = currentPosition.coordinate();
//Declares latitude and longitude
qreal latitude = geoCoordinate.latitude();
qreal longitude = geoCoordinate.longitude();
//Replaces the textlabels with longitude and latitude values
ui->latitudeOutputLabel->setText(QString::number(latitude));
ui->longitudeOutputLabel->setText(QString::number(longitude));
ui->areaLabel->setText(currentPosition.coordinate().toString(QGeo Coordinate::DegreesMinutesWithHemisphere));
};
and i want it called from, so that i dont have to find the coordinates again in this function:
void MainWindow::calcMax() {
//gives maximum values of latitude and longitude
// geoCoordinate.setLatitude(geoCoordinate.latitude() +2);
// geoCoordinate.setLongitude(geoCoordinate.longitude ()+2);
// ui->maxLabel->setText(geoCoordinate.toString(QGeoCoordinate::Deg reesMinutesWithHemisphere));
};
Header:
class MainWindow : public QMainWindow
{
Q_OBJECT
public slots:
void locationUpdated(QGeoPositionInfo);
void calcMax();
void calcMin();
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
QGeoPositionInfoSource* m_source;
Im pretty clueless at this point any help is welcome :)
I'm trying to get a function to call another function from the same class
this is the function i want called:
void MainWindow::locationUpdated(QGeoPositionInfo currentPosition) {
//Defines a geographical position on the surface of the Earth
QGeoCoordinate geoCoordinate = currentPosition.coordinate();
//Declares latitude and longitude
qreal latitude = geoCoordinate.latitude();
qreal longitude = geoCoordinate.longitude();
//Replaces the textlabels with longitude and latitude values
ui->latitudeOutputLabel->setText(QString::number(latitude));
ui->longitudeOutputLabel->setText(QString::number(longitude));
ui->areaLabel->setText(currentPosition.coordinate().toString(QGeo Coordinate::DegreesMinutesWithHemisphere));
};
and i want it called from, so that i dont have to find the coordinates again in this function:
void MainWindow::calcMax() {
//gives maximum values of latitude and longitude
// geoCoordinate.setLatitude(geoCoordinate.latitude() +2);
// geoCoordinate.setLongitude(geoCoordinate.longitude ()+2);
// ui->maxLabel->setText(geoCoordinate.toString(QGeoCoordinate::Deg reesMinutesWithHemisphere));
};
Header:
class MainWindow : public QMainWindow
{
Q_OBJECT
public slots:
void locationUpdated(QGeoPositionInfo);
void calcMax();
void calcMin();
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
QGeoPositionInfoSource* m_source;
Im pretty clueless at this point any help is welcome :)