Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Function not declared in scope
Forum Updated to NodeBB v4.3 + New Features

Function not declared in scope

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DeanQt
    wrote on 22 Feb 2014, 12:05 last edited by
    #1

    @void MainWindow::update_values(double seek)
    {
    ui->doubleSpinBox_19->setValue(seek);
    }

    double goal_seek (double goal, double bound_lower, double bound_upper, double seek) {
    seek = (bound_upper - bound_lower) / 2;
    double goalseek;
    update_values(seek);
    if (abs(goalseek - goal) <= 0.0001)
    return seek;
    else if (goalseek < goal) {
    bound_lower = goalseek;
    return goal_seek(goal, bound_lower, bound_upper, seek);
    }
    else if (goalseek > goal){
    bound_upper = goalseek;
    return goal_seek(goal, bound_lower, bound_upper, seek);
    }
    else
    return -1;
    }

    void MainWindow::button_pushed()
    {
    double seek;
    goal_seek(5);
    update_values(seek);
    }@

    In the function "goal_seek", I want to call a function called update_values. However that line gives an error message saying update_values was not declared in scope.

    I dont see why this is so. Above it, one may see the function declaration.

    More confusing still is the fact that if I call update_values from the function button_pushed() there is no error message saying its not declared in scope.

    Can anyone suggest how to take away the error message?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dbzhang800
      wrote on 22 Feb 2014, 15:29 last edited by
      #2

      Yes, as update_values() is a member of your class MainWindow, while goal_seek() is a global function.

      1 Reply Last reply
      0

      1/2

      22 Feb 2014, 12:05

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved