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. Unknown type name issue
Forum Updated to NodeBB v4.3 + New Features

Unknown type name issue

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 19.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.
  • N Offline
    N Offline
    nicky j
    wrote on last edited by
    #1

    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!

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      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.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • N Offline
        N Offline
        nicky j
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • hskoglundH Offline
          hskoglundH Offline
          hskoglund
          wrote on last edited by
          #4

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

          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