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. Cannot call a function
Forum Update on Monday, May 27th 2025

Cannot call a function

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 3 Posters 760 Views
  • 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.
  • G Offline
    G Offline
    GunkutA
    wrote on 3 Sept 2020, 08:56 last edited by
    #1

    Hello, I cannot call a function from another function. I do not know what is wrong. I have a function that returns double :

        double calculateMathVectors();
    

    That is how it is defined in header under private: section. Then when I try to call it from another function as:

    void protocolForm::receiveMathSignals(QString selected1, QString selected2, QString operation, QString signalName)
    {
        protocolForm::calculateMathVectors();
    }
    

    At the beginning of the called function there is qDebug().

    double protocolForm::calculateMathVectors()
    {
        qDebug()<< "entered";
    .
    .
    .
    }
    

    But it never enters to that qDebug(). How might be wrong? Probably I am missing a very simple thing.

    J K 2 Replies Last reply 3 Sept 2020, 09:09
    0
    • G GunkutA
      3 Sept 2020, 08:56

      Hello, I cannot call a function from another function. I do not know what is wrong. I have a function that returns double :

          double calculateMathVectors();
      

      That is how it is defined in header under private: section. Then when I try to call it from another function as:

      void protocolForm::receiveMathSignals(QString selected1, QString selected2, QString operation, QString signalName)
      {
          protocolForm::calculateMathVectors();
      }
      

      At the beginning of the called function there is qDebug().

      double protocolForm::calculateMathVectors()
      {
          qDebug()<< "entered";
      .
      .
      .
      }
      

      But it never enters to that qDebug(). How might be wrong? Probably I am missing a very simple thing.

      J Offline
      J Offline
      JonB
      wrote on 3 Sept 2020, 09:09 last edited by
      #2

      @GunkutA
      It looks like you should just call it via calculateMathVectors();. However, put a qDebug() into protocolForm::receiveMathSignal() first line, prove that is being called in the first place?

      G 1 Reply Last reply 3 Sept 2020, 09:20
      0
      • G GunkutA
        3 Sept 2020, 08:56

        Hello, I cannot call a function from another function. I do not know what is wrong. I have a function that returns double :

            double calculateMathVectors();
        

        That is how it is defined in header under private: section. Then when I try to call it from another function as:

        void protocolForm::receiveMathSignals(QString selected1, QString selected2, QString operation, QString signalName)
        {
            protocolForm::calculateMathVectors();
        }
        

        At the beginning of the called function there is qDebug().

        double protocolForm::calculateMathVectors()
        {
            qDebug()<< "entered";
        .
        .
        .
        }
        

        But it never enters to that qDebug(). How might be wrong? Probably I am missing a very simple thing.

        K Offline
        K Offline
        KroMignon
        wrote on 3 Sept 2020, 09:19 last edited by KroMignon 9 Mar 2020, 09:20
        #3

        @GunkutA said in Cannot call a function:

        Probably I am missing a very simple thing.

        Perhaps you have to learn a little bit more C++ language basics?
        If you want to call a function from your class, simply call it!

        double protocolForm::calculateMathVectors()
        {
            qDebug()<< "entered";
            ...
        }
        void protocolForm::receiveMathSignals(QString selected1, QString selected2, QString operation, QString signalName)
        {
            calculateMathVectors();
        }
        

        Just another hint, it is recommended to use UpperCamelCase for class names and lowerCamelCase for function names.
        So your class name should be ProtocolForm.

        It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

        G 1 Reply Last reply 3 Sept 2020, 09:21
        3
        • J JonB
          3 Sept 2020, 09:09

          @GunkutA
          It looks like you should just call it via calculateMathVectors();. However, put a qDebug() into protocolForm::receiveMathSignal() first line, prove that is being called in the first place?

          G Offline
          G Offline
          GunkutA
          wrote on 3 Sept 2020, 09:20 last edited by
          #4

          @JonB There is a qDebug() in the first line of protocolForm::receiveMathSignal(). When I simply called calculateMathVectors(); still not entering the function sadly.

          J 1 Reply Last reply 3 Sept 2020, 09:30
          0
          • K KroMignon
            3 Sept 2020, 09:19

            @GunkutA said in Cannot call a function:

            Probably I am missing a very simple thing.

            Perhaps you have to learn a little bit more C++ language basics?
            If you want to call a function from your class, simply call it!

            double protocolForm::calculateMathVectors()
            {
                qDebug()<< "entered";
                ...
            }
            void protocolForm::receiveMathSignals(QString selected1, QString selected2, QString operation, QString signalName)
            {
                calculateMathVectors();
            }
            

            Just another hint, it is recommended to use UpperCamelCase for class names and lowerCamelCase for function names.
            So your class name should be ProtocolForm.

            G Offline
            G Offline
            GunkutA
            wrote on 3 Sept 2020, 09:21 last edited by
            #5

            @KroMignon When I simply call it, still not printing the qDebug().

            K 1 Reply Last reply 3 Sept 2020, 09:23
            0
            • G GunkutA
              3 Sept 2020, 09:21

              @KroMignon When I simply call it, still not printing the qDebug().

              K Offline
              K Offline
              KroMignon
              wrote on 3 Sept 2020, 09:23 last edited by
              #6

              @GunkutA said in Cannot call a function:

              When I simply call it, still not printing the qDebug().

              Are you sure you are running the right code (e.g. do you have build it successfully)?
              Do you have tried to set breakpoint and start in debug mode?

              It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

              G 1 Reply Last reply 3 Sept 2020, 09:40
              1
              • G GunkutA
                3 Sept 2020, 09:20

                @JonB There is a qDebug() in the first line of protocolForm::receiveMathSignal(). When I simply called calculateMathVectors(); still not entering the function sadly.

                J Offline
                J Offline
                JonB
                wrote on 3 Sept 2020, 09:30 last edited by JonB 9 Mar 2020, 09:31
                #7

                @GunkutA said in Cannot call a function:

                @JonB There is a qDebug() in the first line of protocolForm::receiveMathSignal().

                No there isn't, you have shown the code of protocolForm::receiveMathSignals() method and there is no such statement.

                G 1 Reply Last reply 3 Sept 2020, 09:39
                1
                • J JonB
                  3 Sept 2020, 09:30

                  @GunkutA said in Cannot call a function:

                  @JonB There is a qDebug() in the first line of protocolForm::receiveMathSignal().

                  No there isn't, you have shown the code of protocolForm::receiveMathSignals() method and there is no such statement.

                  G Offline
                  G Offline
                  GunkutA
                  wrote on 3 Sept 2020, 09:39 last edited by
                  #8

                  @JonB Yes you are right, I did not connect that slot... My bad and thanks.

                  1 Reply Last reply
                  0
                  • K KroMignon
                    3 Sept 2020, 09:23

                    @GunkutA said in Cannot call a function:

                    When I simply call it, still not printing the qDebug().

                    Are you sure you are running the right code (e.g. do you have build it successfully)?
                    Do you have tried to set breakpoint and start in debug mode?

                    G Offline
                    G Offline
                    GunkutA
                    wrote on 3 Sept 2020, 09:40 last edited by
                    #9

                    @KroMignon I forgot to connect signal and slots, my bad :( and thanks

                    1 Reply Last reply
                    0

                    5/9

                    3 Sept 2020, 09:21

                    • Login

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