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. 'CapturarReceta' was not declare in this scope
Forum Updated to NodeBB v4.3 + New Features

'CapturarReceta' was not declare in this scope

Scheduled Pinned Locked Moved General and Desktop
12 Posts 3 Posters 3.1k 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
    Donluigimx
    wrote on last edited by
    #1

    I have this problem when I declare a private pointer to CapturarReceta, also, in the constructor I get "CapturarReceta has not been declared".
    This is my code (.h):
    @
    #ifndef ADVERTENCIA_H
    #define ADVERTENCIA_H

    #include <QDialog>
    #include <QtGlobal>
    #include <capturarreceta.h>
    #include <ListaD.h>
    #include <Receta.h>
    #include <QPointer>
    namespace Ui {
    class Advertencia;
    }

    class Advertencia : public QDialog
    {
    Q_OBJECT

    public:
    explicit Advertencia(ListaD<Receta>* lista,CapturarReceta* paso,qint8 pas,QWidget *parent = 0);
    ~Advertencia();

    private slots:
    void on_Si_clicked();

    void on_No_clicked();
    

    private:
    Ui::Advertencia *ui;
    CapturarReceta *cr;
    ListaD<Receta> *recetas;
    };

    #endif // ADVERTENCIA_H
    @

    I been tried everything and nothing works.

    1 Reply Last reply
    0
    • X Offline
      X Offline
      Xander84
      wrote on last edited by
      #2

      Hi, can you post your capturarreceta.h? maybe you've used a namespace or something.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        Donluigimx
        wrote on last edited by
        #3

        Hi Xander, this is the code from capturareceta.h:

        @
        #ifndef CAPTURARRECETA_H
        #define CAPTURARRECETA_H

        #include <QWidget>
        #include <QtGlobal>
        #include <advertencia.h>
        #include <menurecetario.h>
        #include "Recetario.h"
        #include "ListaD.h"
        #include "Receta.h"

        namespace Ui {
        class CapturarReceta;
        }

        class CapturarReceta : public QWidget
        {
        Q_OBJECT

        public:
        explicit CapturarReceta(ListaD<Receta>* pos,QWidget *parent = 0);
        ~CapturarReceta();

        private slots:
        void on_Regresar_clicked();

        private:
        Ui::CapturarReceta *ui;
        ListaD<Receta> *recetas;
        };

        #endif // CAPTURARRECETA_H
        @

        I tried declare "Ui::CapturarReceta *cr;" but gives me the same error.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi and welcome to devnet,

          Can you show the Advertencia implementation ?

          Also the complete error could be useful

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • X Offline
            X Offline
            Xander84
            wrote on last edited by
            #5

            Oh I just noticed, you should use
            @
            #include "capturarreceta.h"
            @
            for local files, instead of
            @
            #include <capturarreceta.h>
            @
            yeah there is a difference. :D

            About the Ui namespace, actually CapturarReceta is your "main" class and Ui::CapturarReceta the UI class (generated from the CapturarReceta.ui file), so that is not the same class.

            If you still have a compile error post the exact error message please (with line number etc).

            1 Reply Last reply
            0
            • D Offline
              D Offline
              Donluigimx
              wrote on last edited by
              #6

              Hi!, and thanks.

              This is the code from Advertencia.cpp

              @
              #include "advertencia.h"
              #include "ui_advertencia.h"
              #include <QtGlobal>
              Advertencia::Advertencia(ListaD<Receta> *lista,CapturarReceta *paso, qint8 pas,QWidget *parent) :
              QDialog(parent),
              ui(new Ui::Advertencia)
              {
              ui->setupUi(this);
              setAttribute(Qt::WA_DeleteOnClose,true);
              cr=paso;
              recetas=lista;
              if(pas==1)ui->Mensaje->setText("¿Seguro que deseas regresar al menú anterior?");
              }

              Advertencia::~Advertencia()
              {
              delete ui;
              }

              void Advertencia::on_Si_clicked()
              {
              cr->close();
              MenuRecetario *menu = new MenuRecetario(recetas);
              menu->show();
              close();
              }

              void Advertencia::on_No_clicked()
              {
              close();
              }
              @

              And the complete error:

              bq. C:\Users\Servidor-PC\Desktop\Recetario\capturarreceta.h:6: In file included from ......\Servidor-PC\Desktop\Recetario/capturarreceta.h:6:0,
              C:\Users\Servidor-PC\Desktop\Recetario\menurecetario.h:7: from ......\Servidor-PC\Desktop\Recetario/menurecetario.h:7,
              C:\Users\Servidor-PC\Desktop\Recetario\main.cpp:1: from ......\Servidor-PC\Desktop\Recetario\main.cpp:1:
              C:\Users\Servidor-PC\Desktop\Recetario\advertencia.h:21: error: 'CapturarReceta' has not been declared
              explicit Advertencia(ListaD<Receta>* lista,CapturarReceta* paso,qint8 pas,QWidget *parent = 0);
              ^
              C:\Users\Servidor-PC\Desktop\Recetario\advertencia.h:31: error: 'CapturarReceta' does not name a type
              CapturarReceta *cr;
              ^

              Thanks in advance.

              1 Reply Last reply
              0
              • D Offline
                D Offline
                Donluigimx
                wrote on last edited by
                #7

                [quote author="Xander84" date="1397504057"]Oh I just noticed, you should use
                @
                #include "capturarreceta.h"
                @
                for local files, instead of
                @
                #include <capturarreceta.h>
                @
                yeah there is a difference. :D

                About the Ui namespace, actually CapturarReceta is your "main" class and Ui::CapturarReceta the UI class (generated from the CapturarReceta.ui file), so that is not the same class.

                If you still have a compile error post the exact error message please (with line number etc).[/quote]

                I tried this before, and the error still be the same.

                1 Reply Last reply
                0
                • X Offline
                  X Offline
                  Xander84
                  wrote on last edited by
                  #8

                  You should always try to fix the first error, which is "error: ‘CapturarReceta’ has not been declared explicit", the error after that is just a result of the first error in most cases.
                  As far as I can see you should remove the explicit keyword here:;
                  @
                  explicit Advertencia(ListaD<Receta>* lista,CapturarReceta* paso,qint8 pas,QWidget *parent = 0);
                  @
                  Declaring a constructor explicit only makes sense if you have only one non-default parameter I guess.

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    Donluigimx
                    wrote on last edited by
                    #9

                    [quote author="Xander84" date="1397505508"]You should always try to fix the first error, which is "error: ‘CapturarReceta’ has not been declared explicit", the error after that is just a result of the first error in most cases.
                    As far as I can see you should remove the explicit keyword here:;
                    @
                    explicit Advertencia(ListaD<Receta>* lista,CapturarReceta* paso,qint8 pas,QWidget *parent = 0);
                    @
                    Declaring a constructor explicit only makes sense if you have only one non-default parameter I guess.[/quote]

                    I try deleted "explicit" in all the headers (I did not know what it means explicit). And the error still the same.

                    1 Reply Last reply
                    0
                    • X Offline
                      X Offline
                      Xander84
                      wrote on last edited by
                      #10

                      Ok then I have no idea, maybe it's some weird build error did you try and delete all build folders with the temporary files? With c++ the incremental compiler is sometimes corrupting the files, don't ask me but sometimes a full clean does the trick.. :D

                      If you need a simple explanation what explicit does: http://stackoverflow.com/questions/121162/what-does-the-explicit-keyword-in-c-mean
                      e.g.
                      @
                      QString str = "foo"; // implicit
                      @
                      that does an implicit conversion from char* to QString (calling the QString(char*) constructor), if you declare the constructor with explicit you can't do that and have so explicitly call it, in this case:
                      @
                      QString str = QString("foo"); // explicit
                      @

                      1 Reply Last reply
                      0
                      • D Offline
                        D Offline
                        Donluigimx
                        wrote on last edited by
                        #11

                        [quote author="Xander84" date="1397506445"]Ok then I have no idea, maybe it's some weird build error did you try and delete all build folders with the temporary files? With c++ the incremental compiler is sometimes corrupting the files, don't ask me but sometimes a full clean does the trick.. :D

                        [/quote]

                        I tried in 3 different PC´s, Linux and Windows, and the error still there. With every object I declare on this class, throw the same error.

                        1 Reply Last reply
                        0
                        • X Offline
                          X Offline
                          Xander84
                          wrote on last edited by
                          #12

                          If it is possible for you do share the source code or at least the class and all dependencies I could try it to compile it myself, problem with some errors like this is like fishing in the dark, you can try some things that is not easily done over the forums I guess.. maybe someone else has an idea but I don't see any syntax errors from here.

                          1 Reply Last reply
                          0

                          • Login

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