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. [SOLVED] Creating Instance of dialog error
Forum Update on Monday, May 27th 2025

[SOLVED] Creating Instance of dialog error

Scheduled Pinned Locked Moved General and Desktop
17 Posts 4 Posters 9.5k 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.
  • V Offline
    V Offline
    vezprog
    wrote on 26 Sept 2011, 14:11 last edited by
    #7

    Yes, i fixed it.... This isnt my actual code. I am just recreating an example of what I am doing. That was just a typo on my part in recreating the example. The typo is not present in my actual code.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mindomobile
      wrote on 26 Sept 2011, 14:17 last edited by
      #8

      I tried to create test app from your example and everything works as you expected.

      So my only suggestions could be to check whether or not your class is called "dialog" or "Dialog" (case sensitive).

      You also don't need to include dialog.h twice, so you can remove it from mainwindow.cpp file (optional).

      As I mentioned earlier, try to locate the line where there error pops up. Check the line and couple lines above you might find some bug there.

      Mobile application development | <a href="http://mindomobile.com">mindomobile.com</a>

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Robbin
        wrote on 26 Sept 2011, 14:28 last edited by
        #9

        Are you building your app from within QtCreator? Try cleaning up your project first, then rebuild it. If you did a typo in the class definition, it might have "remembered" the old definition.

        1 Reply Last reply
        0
        • V Offline
          V Offline
          vezprog
          wrote on 26 Sept 2011, 14:28 last edited by
          #10

          I commented out all of the instantiations. and dialog.exec() 's and the error when bye bye... so now I am confused!

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mindomobile
            wrote on 26 Sept 2011, 14:30 last edited by
            #11

            [quote author="dvez43" date="1317047321"]I commented out all of the instantiations. and dialog.exec() 's and the error when bye bye... so now I am confused![/quote]

            Did you checked the class name for dialog? Try to comment definition in mainwindow.h file.

            Mobile application development | <a href="http://mindomobile.com">mindomobile.com</a>

            1 Reply Last reply
            0
            • V Offline
              V Offline
              vezprog
              wrote on 26 Sept 2011, 14:35 last edited by
              #12

              thats what I did I believe. As in definition do you mean instantiation? (thats kinda what I use for the terminology) :P

              I commented out the definitions/instantiations in the mainwindow.h and the .exec() in mainwindow.cpp and the error disappears and the program compiles correctly.

              This dialog box dialog has its own class file as well and also a .ui file since I am using Qt designer.

              1 Reply Last reply
              0
              • R Offline
                R Offline
                Robbin
                wrote on 26 Sept 2011, 14:38 last edited by
                #13

                I think he meant the class definition in your dialog.h
                If you built it using Qt Designer, it shouldn't have possible errors/typos, but it wouldn't hurt if we look at it as well you know? :P

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mindomobile
                  wrote on 26 Sept 2011, 14:40 last edited by
                  #14

                  So if you created a dialog using Qt Creator and you haven't change a single thing during wizard you should try change:

                  @dialog dia;@

                  to

                  @Dialog dia;@

                  in mainwindow.h file and try to recompile...

                  Mobile application development | <a href="http://mindomobile.com">mindomobile.com</a>

                  1 Reply Last reply
                  0
                  • V Offline
                    V Offline
                    vezprog
                    wrote on 26 Sept 2011, 14:41 last edited by
                    #15

                    Heres my dialog.h file

                    @

                    #ifndef DIALOG_H
                    #define DIALOG_H

                    #include <QDialog>

                    namespace Ui {
                    class dialog;
                    }

                    class dialog : public QDialog
                    {
                    Q_OBJECT

                    public:
                    explicit dialog(QWidget *parent = 0);
                    ~dialog();

                    public slots:

                    private:
                    Ui::dialog *ui;
                    };

                    #endif // DIALOG_H

                    @

                    EDIT:
                    My actual dialog that I did create is named "settings", its to set settings on the serial port being used in my application. I use this dialog box twice within the mainwindow since if the user resets the settings then the object has to be destroyed, and then recreated. I am trying to make my class instantiation global throughout mainwindow.cpp. And I am failing epically :P

                    so instead of dialog everywhere, you would see settings... so in my header file for mainwindow.cpp i have settings diasettings; as my instantiation

                    1 Reply Last reply
                    0
                    • V Offline
                      V Offline
                      vezprog
                      wrote on 26 Sept 2011, 15:22 last edited by
                      #16

                      I did end up figuring out the problem.

                      I defined my dialog as a QDialog *setdialog in my headerfile

                      and set settings as a object of settings

                      this->setdialog = new settings(this);

                      worked fine. good lord.

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        mlong
                        wrote on 26 Sept 2011, 21:01 last edited by
                        #17

                        Be sure and edit the thread topic to add [Solved] at the beginning. Thanks!

                        Software Engineer
                        My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

                        1 Reply Last reply
                        0

                        16/17

                        26 Sept 2011, 15:22

                        • Login

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