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. Need Help: "Dialog does not name a type" Error
Forum Update on Monday, May 27th 2025

Need Help: "Dialog does not name a type" Error

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 3.3k 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.
  • H Offline
    H Offline
    hadifyassin
    wrote on 30 Nov 2016, 07:05 last edited by hadifyassin
    #1

    Re: [SOLVED]Need Help: Error " 'CLASS' does not name a type"
    First of all, I understand that this question has already been asked and I did understand the answer by @sierdzio but IDK how to fix it. What other way to open windows when button is pressed? And the site told me to create a new post.
    I also know this looks long but that's only because I've made it as readable as I can.
    I have a program in which a push button in a window opens a second window. The second window has a 'back' button which opens the first window.
    But in the second window I'm getting the error.
    NOTE: I'm only pasting part of the code so as to make it readable.
    Dialog.h(first window)

    #include <QDialog>
    #include "calculator.h"
    #include "imp.h"
    #include "perc.h"

    //standard codes that is automatically added on creating new dialog window in Qt

    private slots:
    void on_pushButton_clicked();

    void on_pushButton_9_clicked();
    
    void on_pushButton_8_clicked();
    
    void on_pushButton_2_clicked();
    
    void on_pushButton_3_clicked();
    

    private:
    Ui::Dialog *ui;
    //all the windows that will open from this window
    calculator *calc;
    Imp *pa;
    Perc *per;

    imp.h(second window)

    #include <QDialog>
    #include "dialog.h"

    //standard codes that is automatically added on creating new dialog window in Qt

    private slots:
    void on_pushButton_clicked();

    void on_pushButton_2_clicked();
    

    private:
    Ui::Imp *ui;
    Dialog *secdialog;

    dialog.cpp(first window)
    #include "dialog.h"
    #include "ui_dialog.h"
    #include "mainwindow.h"

    //all the usual error-free(I think) code

    void Dialog::on_pushButton_2_clicked()
    {
    hide();
    pa=new Imp(this);
    pa->show();
    }

    imp.cpp(second window)

    #include "imp.h"
    #include "ui_imp.h"
    #include<QTextStream>
    #include<QFile>
    #include<QFileDialog>

    //all the usual error-free(I think) code

    void Imp::on_pushButton_2_clicked()
    {
    hide();
    secdialog=new Dialog(this);
    secdialog->show();
    }

    The error is in imp.h(2nd window) this line: Dialog *secdialog;
    The error says "Dialog does not name a type".
    Also note that dialog is not the main window but a window that opens many other windows when push button is pressed.

    PLEASE HELP ME WITH THIS AND THANKS IN ADVANCE.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 30 Nov 2016, 07:18 last edited by mrjj
      #2

      Hi and welcome

      The error says "Dialog does not name a type".

      Which means its missing its .h file.
      so in imp.ccp you must also have
      #include "dialog.h"
      So it know the custom type Dialog.

      like this test project
      https://www.dropbox.com/sh/cnvtmg831zvuex5/AADWKcdHF7K1qJKUE1a7atAMa?dl=0

      H 1 Reply Last reply 30 Nov 2016, 17:23
      5
      • M mrjj
        30 Nov 2016, 07:18

        Hi and welcome

        The error says "Dialog does not name a type".

        Which means its missing its .h file.
        so in imp.ccp you must also have
        #include "dialog.h"
        So it know the custom type Dialog.

        like this test project
        https://www.dropbox.com/sh/cnvtmg831zvuex5/AADWKcdHF7K1qJKUE1a7atAMa?dl=0

        H Offline
        H Offline
        hadifyassin
        wrote on 30 Nov 2016, 17:23 last edited by hadifyassin
        #3

        @mrjj THANKS A MILLION!!! REAL LIFESAVER!
        BTW (small doubt): The error was in imp.h but I did include "dialog" in imp.h. The program worked when I removed those lines from the header and placed them in imp.cpp but I am confused as to why the previous configuration doesn't give the same result. Pls Clarify this as well.
        Thanks again!

        1 Reply Last reply
        1
        • M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 1 Dec 2016, 13:32 last edited by
          #4

          Hi
          :)

          • The program worked when I removed those lines from the header and placed them in imp.cpp

          That is a bid odd as it should have complained again.
          Did you Clean All - Rebuild all to really check?

          1 Reply Last reply
          2
          • H Offline
            H Offline
            hadifyassin
            wrote on 19 Dec 2016, 18:37 last edited by
            #5

            Yes, I did. And it works! IDK what's supposed to happen but this really works.

            1 Reply Last reply
            1

            • Login

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