Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

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

    General and Desktop
    2
    5
    2399
    Loading More Posts
    • 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
      hadifyassin last edited by hadifyassin

      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 Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by mrjj

        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 Reply Quote 5
        • H
          hadifyassin @mrjj last edited by hadifyassin

          @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 Reply Quote 1
          • mrjj
            mrjj Lifetime Qt Champion last edited by

            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 Reply Quote 2
            • H
              hadifyassin last edited by

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

              1 Reply Last reply Reply Quote 1
              • First post
                Last post