Unknown type name issue



  • Hello there,

    I am starting a project and I am having trouble compiling it. Every time I hit the 'run' button, it fails to compile and throws me the following error:

    /Users/XXXX/Desktop/Development/QT dev/quarkBrowser_v1/mainview.h:22: error: unknown type name 'tranquility'
    tranquility *tranq;
    ^

    I'm not sure what it means by 'unknown type name 'tranquility''. tranquility is a class I made based of a QWidget. I am trying to add a tranquility widget to my MainView class (QMainWindow) when I receive the error.

    Here is my code:
    mainview.h:
    @#ifndef MAINVIEW_H
    #define MAINVIEW_H

    #include <QXmlQuery>
    #include <QMainWindow>
    #include <QXmlSerializer>
    #include <QXmlResultItems>
    #include <QStackedWidget>
    #include <QWidget>
    #include <QWebView>

    #include "tranquility.h"

    class MainView : public QMainWindow
    {
    Q_OBJECT

    public:
    MainView(QWidget *parent = 0);
    ~MainView();

    tranquility *tranq;
    QStackedWidget *stack;
    

    private:

    };

    #endif // MAINVIEW_H
    @

    mainview.cpp:
    @#include "mainview.h"

    MainView::MainView(QWidget *parent)
    : QMainWindow(parent)
    {
    stack = new QStackedWidget;

    tranq = new tranquility;

    stack->addWidget(tranq);

    setCentralWidget(stack);
    }

    MainView::~MainView()
    {

    }
    @

    tranquility.h:
    @
    #ifndef TRANQUILITY_H
    #define TRANQUILITY_H

    #include <QWidget>
    #include <QWidget>
    #include <QPointer>
    #include <QLineEdit>
    #include <QWebView>
    #include <QToolBar>
    #include <QObject>
    #include <QTextEdit>
    #include <QKeySequence>
    #include <QActionGroup>
    #include <QTimer>
    #include <QDebug>
    #include <QVBoxLayout>
    #include <QTabWidget>
    #include <QToolButton>
    #include <QTabBar>

    #include "browsetab.h"

    class tranquility : public QWidget
    {
    Q_OBJECT
    public:
    explicit tranquility(QWidget *parent = 0);

    QWebView *webView;
    

    signals:

    public slots:

    protected slots:

    private:

    };

    #endif // TRANQUILITY_H
    @

    tranquility.cpp:
    @#include "tranquility.h"

    tranquility::tranquility(QWidget *parent) :
    QWidget(parent)
    {

    }
    @

    The error appears next to 'tranquility *tranq' in mainview.h
    I am super stumped, and any help would be appreciated!
    Thanks for your time!



  • This issue of header file not found. Where is your tranquility.h ? Is it in the same directory as MainWindow.h ? If it is in different path just add INCLUDEPATH directive in your .pro file, re-run qmake, build it and run your program.



  • tranquility.h IS located in the same directory as MainWindow.h



  • Hi, hmmm it could maybe be some problem with your browsetab.h file, could you post it?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.