Results 1 to 7 of 7

Thread: QDialog problem

  1. #1

    Default QDialog problem

    Hello everyone, I am making a QT GUI project and I want a QDialog to pop-up when the user selects some option in the program.. I added the Qt Designer form to the project.. I read that the way you call the QDialog is by doing exec(); function. However, the program compiler says that "the dialog was not declared in this scope" basically my question is.. other than adding the ui form to the project.. how do you implement the dialog? how do u call it? do u have to make a class source file for the dialog?

    thanks for the help!

  2. #2
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QDialog problem

    There is to many unknown, without seeing actual code, but show QDialog like this:
    qDlgExampl..zip

    Best luck

  3. #3
    Join Date
    Nov 2009
    Location
    Sacramento, CA
    Posts
    24
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QDialog problem

    Here is the doc for using and setting up UI files. There is multiple ways to get at them. Enjoy the read!

    http://opendocs.net/qt/4.6/designer-...a-ui-file.html

  4. #4

    Default Re: QDialog problem

    Thanks for the help talei! I almost got it.. however when I go to fileDialog.ui in the designer and I try to add a slot.. it says that "NO DOCUMENTS MATCHING 'ui_fileDialog.h' could be found. Rebuilding the project might help"
    any ideas???

    I attached the two ui forms Needed for the program..

    here is my whole code.. I would appreciate if you could take a look.. thank you!!

    this is my fileDialog.h
    Qt Code:
    1. #ifndef FILEDIALOG_H
    2. #define FILEDIALOG_H
    3.  
    4.  
    5. #include <QDialog>
    6.  
    7. namespace Ui {
    8. class fileDialog;
    9. }
    10.  
    11. class fileDialog : public QDialog {
    12. Q_OBJECT
    13. public:
    14. fileDialog(QWidget *parent = 0);
    15. ~fileDialog();
    16.  
    17. protected:
    18. void changeEvent(QEvent *e);
    19.  
    20. private:
    21. Ui::fileDialog *ui;
    22. };
    23.  
    24. #endif // FILEDIALOG_H
    To copy to clipboard, switch view to plain text mode 

    this is my fileDialog.cpp
    Qt Code:
    1. #include "fileDialog.h"
    2. #include "ui_filedialog.h"
    3.  
    4.  
    5.  
    6. fileDialog::fileDialog(QWidget *parent) :
    7. QDialog(parent),
    8. ui(new Ui::fileDialog)
    9. {
    10. ui->setupUi(this);
    11. }
    12.  
    13. fileDialog::~fileDialog()
    14. {
    15. delete ui;
    16. }
    17.  
    18. void fileDialog::changeEvent(QEvent *e)
    19. {
    20. QDialog::changeEvent(e);
    21. switch (e->type()) {
    22. case QEvent::LanguageChange:
    23. ui->retranslateUi(this);
    24. break;
    25. default:
    26. break;
    27. }
    28. }
    To copy to clipboard, switch view to plain text mode 
    and this is main
    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include "intercompany.h"
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication a(argc, argv);
    7. Intercompany w;
    8. w.show();
    9. return a.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 



    this is my Intercompany.cpp
    Qt Code:
    1. #ifndef INTERCOMPANY_H
    2. #define INTERCOMPANY_H
    3.  
    4. #include <QMainWindow>
    5. #include "fileDialog.h"
    6.  
    7. namespace Ui {
    8. class Intercompany;
    9. }
    10.  
    11. class Intercompany : public QMainWindow {
    12. Q_OBJECT
    13. public:
    14. Intercompany(QWidget *parent = 0);
    15. ~Intercompany();
    16.  
    17. protected:
    18. void changeEvent(QEvent *e);
    19.  
    20. private:
    21. Ui::Intercompany *ui;
    22. QString date;
    23. QString user;
    24. QString from;
    25. QString to;
    26. QString currentItem;
    27. double currentAmount;
    28. fileDialog *fDialog;
    29.  
    30.  
    31. private slots:
    32. void on_addButton1_clicked();
    33. void on_createButton_clicked();
    34. void on_actionEXIT_triggered();
    35. };
    36.  
    37. #endif // INTERCOMPANY_H}
    To copy to clipboard, switch view to plain text mode 

    this is my intercompany.h
    Qt Code:
    1. #ifndef INTERCOMPANY_H
    2. #define INTERCOMPANY_H
    3.  
    4. #include <QMainWindow>
    5. #include "fileDialog.h"
    6.  
    7. namespace Ui {
    8. class Intercompany;
    9. }
    10.  
    11. class Intercompany : public QMainWindow {
    12. Q_OBJECT
    13. public:
    14. Intercompany(QWidget *parent = 0);
    15. ~Intercompany();
    16.  
    17. protected:
    18. void changeEvent(QEvent *e);
    19.  
    20. private:
    21. Ui::Intercompany *ui;
    22. QString date;
    23. QString user;
    24. QString from;
    25. QString to;
    26. QString currentItem;
    27. double currentAmount;
    28. fileDialog *fDialog;
    29.  
    30.  
    31. private slots:
    32. void on_addButton1_clicked();
    33. void on_createButton_clicked();
    34. void on_actionEXIT_triggered();
    35. };
    36.  
    37. #endif // INTERCOMPANY_H
    To copy to clipboard, switch view to plain text mode 
    Attached Files Attached Files
    Last edited by bostero22; 1st May 2010 at 03:54.

  5. #5
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QDialog problem

    Try to build-> clean all/project and then rebuild, ui files are only XML's, and ui_className.h are automatically created by qDesigner (qtCreator). Sometimes that happens, and the warning say what You should do, rebuild the project.
    See this: qDlgExampl..zip to get better overview how to work with signal and interact between forms.
    Also use F1 (in qtCreator) on classes/methods to know what they are doing.
    And read some good literature about c++/qt programming.
    Best luck.

  6. #6
    Join Date
    Nov 2011
    Posts
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QDialog problem

    I guess you have renamed your files which just changed the upper case or lower case.
    That would make Qt confusing because somewhere in Qt it doesn't care about incasesitive but the file system.

    So, you should check:
    1) The #include statement in your source code: does include file has been renamed accordingly
    2) In your .ui file: are there any line of code that reference to your file and it's name is correctly casesitive.

  7. #7
    Join Date
    Nov 2009
    Location
    Laval, France
    Posts
    124
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDialog problem

    I would just like to add that I had this problem: The solution is to make sure that the project file and the file names of the form files have exactly the same case.

Similar Threads

  1. Problem with QDialog
    By sudhansu in forum Qt Programming
    Replies: 0
    Last Post: 8th March 2010, 11:11
  2. Problem with QDialog
    By sudheer168 in forum Qt Programming
    Replies: 2
    Last Post: 2nd December 2009, 13:26
  3. QDialog and resizing problem...
    By TemporalBeing in forum Qt Programming
    Replies: 7
    Last Post: 27th March 2009, 16:16
  4. connect problem QDialog
    By Zergi in forum Newbie
    Replies: 1
    Last Post: 1st January 2008, 14:36
  5. QDialog / QListView problem
    By harakiri in forum Qt Programming
    Replies: 1
    Last Post: 10th July 2007, 19:31

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.