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. Header file gives a error
Forum Updated to NodeBB v4.3 + New Features

Header file gives a error

Scheduled Pinned Locked Moved General and Desktop
4 Posts 4 Posters 1.9k 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.
  • B Offline
    B Offline
    browser90
    wrote on last edited by
    #1

    I'm making a UI in Qt and need to have input.h included in spel.h, when I use input.h in my mainwindow.h everything works but I also need him in my spel.h and then QT gives these errors:

    @expected ')' before '' token Input.h R 9
    ISO C++ forbids declaration of 'Form' with no type Input.h R 13
    expected ';' before '
    ' token Input.h R13 @

    The input.h file:

    @#ifndef INPUT_H
    #define INPUT_H
    #include "form.h"

    class Input
    {

    public:
    Input(Form * pointer):speler(pointer){}
    int geefGoederenPopup(void);

    private:
    Form * speler;
    };

    #endif // INPUT_H
    @

    form.h

    @#ifndef FORM_H
    #define FORM_H

    #include <QWidget>
    #include "mainwindow.h"

    namespace Ui {
    class Form;
    }

    class Form : public QWidget
    {
    Q_OBJECT

    public:
    explicit Form(QWidget *parent = 0);
    int geefGoederen(void);
    ~Form();

    private:
    Ui::Form *ui;
    };

    #endif // FORM_H
    @

    Can someone help please? How can I have in Spel.h a pointer to my input , because I can't include them I've got a big problem.

    Kind regards,

    1 Reply Last reply
    0
    • K Offline
      K Offline
      Kxyu
      wrote on last edited by
      #2

      Form is definetly not a type for input.h. Obviously, because it is declared in Ui namespace. Try writing Ui::Form instead.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        giesbert
        wrote on last edited by
        #3

        [quote author="Kxyu" date="1321904866"]Form is definetly not a type for input.h. Obviously, because it is declared in Ui namespace. Try writing Ui::Form instead.[/quote]

        His class is also named Form ;-)

        You could remove the #include form.h from input.h and use a forward declaration:

        @
        class Form;
        @

        Nokia Certified Qt Specialist.
        Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          But even with the #include, the pointer type should be known. The code looks ok to me. Something different must be going wrong.

          http://www.catb.org/~esr/faqs/smart-questions.html

          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