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(QGeoCoordinate::DegreesMinutesWithHemisphere));
};
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(QGeoCoordinate::DegreesMinutesWithHemisphere));
};
To copy to clipboard, switch view to plain text mode
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::DegreesMinutesWithHemisphere));
};
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::DegreesMinutesWithHemisphere));
};
To copy to clipboard, switch view to plain text mode
Header:
{
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;
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;
To copy to clipboard, switch view to plain text mode
Im pretty clueless at this point any help is welcome
Bookmarks