Results 1 to 8 of 8

Thread: Getting a function to call another function

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2007
    Posts
    131
    Thanks
    17
    Thanked 4 Times in 2 Posts

    Default Getting a function to call another function

    Hello everyone
    I'm trying to get a function to call another function from the same class
    this is the function i want called:
    Qt Code:
    1. void MainWindow::locationUpdated(QGeoPositionInfo currentPosition) {
    2. //Defines a geographical position on the surface of the Earth
    3. QGeoCoordinate geoCoordinate = currentPosition.coordinate();
    4.  
    5. //Declares latitude and longitude
    6. qreal latitude = geoCoordinate.latitude();
    7. qreal longitude = geoCoordinate.longitude();
    8.  
    9. //Replaces the textlabels with longitude and latitude values
    10. ui->latitudeOutputLabel->setText(QString::number(latitude));
    11. ui->longitudeOutputLabel->setText(QString::number(longitude));
    12. ui->areaLabel->setText(currentPosition.coordinate().toString(QGeoCoordinate::DegreesMinutesWithHemisphere));
    13. };
    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:
    Qt Code:
    1. void MainWindow::calcMax() {
    2.  
    3. //gives maximum values of latitude and longitude
    4. // geoCoordinate.setLatitude(geoCoordinate.latitude()+2);
    5. // geoCoordinate.setLongitude(geoCoordinate.longitude()+2);
    6. // ui->maxLabel->setText(geoCoordinate.toString(QGeoCoordinate::DegreesMinutesWithHemisphere));
    7.  
    8. };
    To copy to clipboard, switch view to plain text mode 

    Header:
    Qt Code:
    1. class MainWindow : public QMainWindow
    2. {
    3. Q_OBJECT
    4.  
    5. public slots:
    6. void locationUpdated(QGeoPositionInfo);
    7. void calcMax();
    8. void calcMin();
    9.  
    10.  
    11. public:
    12. explicit MainWindow(QWidget *parent = 0);
    13. ~MainWindow();
    14.  
    15. private:
    16. Ui::MainWindow *ui;
    17. QGeoPositionInfoSource* m_source;
    To copy to clipboard, switch view to plain text mode 

    Im pretty clueless at this point any help is welcome
    Last edited by bmn; 9th December 2010 at 13:45.

Similar Threads

  1. Qt function call in vb.net
    By abghosh in forum Qt Programming
    Replies: 7
    Last Post: 6th March 2010, 18:00
  2. Call to database function.
    By retto in forum Qt Programming
    Replies: 1
    Last Post: 14th September 2009, 13:29
  3. call function as Qstring
    By jcr in forum Qt Programming
    Replies: 1
    Last Post: 30th May 2009, 02:35
  4. call variable from other function
    By walito in forum Newbie
    Replies: 7
    Last Post: 31st August 2007, 19:36
  5. function call
    By Walsi in forum Qt Programming
    Replies: 3
    Last Post: 12th June 2007, 10:13

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.