Results 1 to 3 of 3

Thread: Problem with second Ui::dialog (Visual Studio QT Add in)

  1. #1
    Join Date
    Apr 2021
    Posts
    4
    Thanks
    4
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Windows

    Default Problem with second Ui::dialog (Visual Studio QT Add in)

    Hello,

    I am trying to build an application with a mainwindow and two dialogs.
    I have successfully created the first dialog. Everything is working just fine.

    Now I wanted to create a second dialog. I created it exactly the same way I was creating the first one.

    But now there are several error messages popping up.

    I dont know what to do or what I did wrong.

    I created both dialogs the same way (almost copy and paste)

    the .h file looks like that (for the first and second dialog):
    Qt Code:
    1. #pragma once
    2. #ifndef SECONDDIALOG_H
    3. #define SECONDDIALOG_H
    4.  
    5. #include "ui_seconddialog.h"
    6. #include <QDialog>
    7. #include <QCloseEvent>
    8.  
    9. namespace Ui
    10. {
    11. class seconddialog;
    12. }
    13.  
    14. class seconddialog: public QDialog
    15. {
    16. Q_OBJECT
    17.  
    18. public:
    19. explicit seconddialog(QWidget* parent = 0);
    20. ~seconddialog();
    21.  
    22.  
    23. public slots:
    24.  
    25. protected:
    26. void closeEvent(QCloseEvent* event);
    27.  
    28. private:
    29. Ui::Dialog ui;
    30.  
    31. private slots:
    32. }
    To copy to clipboard, switch view to plain text mode 


    the .cpp file

    Qt Code:
    1. #include "seconddialog.h"
    2.  
    3.  
    4. Voreinstellungsdialog::Voreinstellungsdialog(QWidget* parent)
    5. : QDialog(parent)
    6. {
    7. ui.setupUi(this);
    8. //more code...
    9.  
    10. }
    To copy to clipboard, switch view to plain text mode 

    in my mainwindow application I am including both dialogs like this.

    mainwindow.h file:

    Qt Code:
    1. #include "firstdialog.h"
    2. #include "seconddialog.h"
    To copy to clipboard, switch view to plain text mode 


    I receive plenty of error messages.

    first main error message:

    C2011 "Ui_Dialog": "class" Type redefinition
    (Source file is compiled main.cpp) QtWidgetsApplication7 C:\Users\lauer\source\repos\QtWidgetsApplication7\ QtWidgetsApplication7\x64\Debug\uic\ui_Messdialog. h 25
    other error message:
    C2011 "Ui:: Dialog": "class" Type redefinition
    (Source file is compiled main.cpp) QtWidgetsApplication7 C:\Users\lauer\source\repos\QtWidgetsApplication7\ QtWidgetsApplication7\x64\Debug\uic\ui_Messdialog. h 25
    other error message:
    C2027 Use of the undefined type "Ui:: Dialog" QtWidgetsApplication7 C:\Users\lauer\source\repos\QtWidgetsApplication7\ QtWidgetsApplication7\Messdialog.cpp 15

  2. #2
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    545
    Thanked 84 Times in 79 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with second Ui::dialog (Visual Studio QT Add in)

    You should name the dialog in the ui file different from the first one.

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,941
    Thanks
    276
    Thanked 803 Times in 792 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Problem with second Ui::dialog (Visual Studio QT Add in)

    C2027 Use of the undefined type "Ui:: Dialog" QtWidgetsApplication7 C:\Users\lauer\source\repos\QtWidgetsApplication7\ QtWidgetsApplication7\Messdialog.cpp 15
    In your seconddialog class definition, you have declared a member variable of the type Ui:: Dialog. There is no such class. Your code should read:

    Qt Code:
    1. private:
    2. Ui::seconddialog ui;
    To copy to clipboard, switch view to plain text mode 

    (Assuming that you named the Ui class "seconddialog" in your .ui file. Whatever you named it, the name in the ui file must match the name you use in your QDialog class definition.)
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 2
    Last Post: 5th March 2021, 21:29
  2. Using Qt 5.4.1 Visual Studio 2013 libs in Visual Studio 2010
    By ^NyAw^ in forum Installation and Deployment
    Replies: 0
    Last Post: 6th March 2015, 10:20
  3. Visual Studio Plugin (1.1.6) crashes Visual Studio (2010)
    By mboeni in forum Installation and Deployment
    Replies: 0
    Last Post: 11th October 2010, 16:46
  4. Visual Studio conversion problem
    By skepticalgeek in forum Qt Programming
    Replies: 0
    Last Post: 4th August 2010, 09:10
  5. qt with visual studio 2005; lib problem
    By jambrek in forum Installation and Deployment
    Replies: 7
    Last Post: 30th January 2008, 22:11

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.