Results 1 to 20 of 20

Thread: Using 2 ui files in a project

  1. #1
    Join Date
    Dec 2012
    Posts
    27
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Using 2 ui files in a project

    I have a QDialog with a pushbutton on it, and when I click the pushbutton, I want another QDialog window in a separate ui file to open. I have a dialog class (with the pushbutton in), but I can't figure out how to use the other ui file to create the window. I've included settings.h (the file that's automatically generated when I compile the program) and added it to the Ui namespace, then tried to create a settings object with "Ui::settings foo;", but I keep getting the same compiler error:

    "c:\programs\qt\sim\dialog.h:67: error: C2079: 'Dialog::foo' uses undefined class 'Ui::settings'"

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Using 2 ui files in a project

    You may not have included the required ui file. See if this sample helps

    Qt Code:
    1. #include "ui_OtherDialog.h"
    2.  
    3. void Dialog::on_pushButton_Clicked()
    4. {
    5. QDialog * other_parent = new QDialog(this);
    6. Ui::OtherDialog other_ui;
    7.  
    8. other_ui.setupUi(other_parent);
    9.  
    10. other_parent.exec();
    11. }
    To copy to clipboard, switch view to plain text mode 
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3
    Join Date
    Dec 2012
    Posts
    27
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Using 2 ui files in a project

    Quote Originally Posted by Santosh Reddy View Post
    You may not have included the required ui file. See if this sample helps

    Qt Code:
    1. #include "ui_OtherDialog.h"
    2.  
    3. void Dialog::on_pushButton_Clicked()
    4. {
    5. QDialog * other_parent = new QDialog(this);
    6. Ui::OtherDialog other_ui;
    7.  
    8. other_ui.setupUi(other_parent);
    9.  
    10. other_parent.exec();
    11. }
    To copy to clipboard, switch view to plain text mode 
    Hmm... Just tried that, but now I'm getting an error whenever I access a member of ui (in the dialog class):

    dialog.cpp:

    Qt Code:
    1. #include "dialog.h"
    2. #include "ui_dialog.h"
    3.  
    4. Dialog::Dialog(QWidget *parent):
    5. QDialog(parent),
    6. ui(new Ui::Dialog),
    7. {
    8. srand(time(0));
    9. ui->setupUi(this);
    10. ui->label->setVisible(false);
    11. }
    12.  
    13. void Dialog::on_pushButton_clicked(){ //settings
    14. QDialog *parent = new QDialog(this);
    15. Ui::settings foo;
    16.  
    17. foo.setupUi(parent);
    18. parent->exec();
    19. }
    To copy to clipboard, switch view to plain text mode 

    dialog.h:

    Qt Code:
    1. #ifndef DIALOG_H
    2. #define DIALOG_H
    3.  
    4. #include <QDialog>
    5. #include <QtCore>
    6. #include <QtGui>
    7. #include "settings.h"
    8. #include "ui_settings.h"
    9.  
    10. namespace Ui {
    11. class Dialog;
    12. class settings;
    13. }
    14.  
    15. class Dialog : public QDialog
    16. {
    17. Q_OBJECT
    18.  
    19. public:
    20. Ui::Dialog *ui;
    21. explicit Dialog(QWidget *parent = 0);
    22. ~Dialog();
    23.  
    24. private slots:
    25. void on_pushButton_clicked();
    26. };
    27.  
    28. #endif // DIALOG_H
    To copy to clipboard, switch view to plain text mode 

    Now, I get errors whenever I have "ui->" in my code.
    Last edited by ben1996123; 3rd January 2013 at 16:51.

  4. #4
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Using 2 ui files in a project

    Can you post the error?
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  5. #5
    Join Date
    Dec 2012
    Posts
    27
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Using 2 ui files in a project

    Quote Originally Posted by Santosh Reddy View Post
    Can you post the error?
    C:\programs\Qt\sim-build-desktop-Qt_4_8_1_for_Desktop_-_MSVC2010__Qt_SDK__Release\..\sim\dialog.cpp:21: error: C2027: use of undefined type 'Ui::Dialog'
    C:\programs\Qt\sim-build-desktop-Qt_4_8_1_for_Desktop_-_MSVC2010__Qt_SDK__Release\..\sim\dialog.cpp:21: error: C2227: left of '->setupUi' must point to class/struct/union/generic type

  6. #6
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Using 2 ui files in a project

    @ben: I think you are totally confused about how to go about what you want to do. You should not need to access the ui pointer in your other dialog at all. Ui pointers are meant to be hidden inside the widget classes that define them, so that they can access the signals, slots, and properties of the widgets defined in the ui file.

    To invoke a second dialog as a response to a button click in the first dialog, all you need to do is something like this:

    Qt Code:
    1. // Dialog1.cpp:
    2. #include "Dialog1.h"
    3. #include "Dialog2.h"
    4.  
    5. Dialog1::Dialog1( QWidget * parent )
    6. : QDialog( parent )
    7. , ui( new Ui::Dialog1 )
    8. {
    9. ui->setupUi( this );
    10.  
    11. connect( ui->someButton, SIGNAL( clicked() ), this, SLOT( showDialog2() ) );
    12. }
    13.  
    14. void Dialog1::showDialog2()
    15. {
    16. Dialog2 dlg2( this );
    17. dlg2->exec();
    18. }
    To copy to clipboard, switch view to plain text mode 

    where of course, you have defined the showDialog2 slot correctly in the Dialog1.h header. The "ui" pointers in the Dialog1 and Dialog2 classes should be declared as private, since there is absolutely no reason to access them from outside of the class the uses them.

    If there are any signals or slots in Dialog2 that need to be "watched" from inside of Dialog1, then set up the connections in showDialog2(). These will automatically be disconnected when dlg2 goes out of scope at the end of showDialog2().

  7. #7
    Join Date
    Dec 2012
    Posts
    27
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Using 2 ui files in a project

    Quote Originally Posted by d_stranz View Post
    @ben: I think you are totally confused about how to go about what you want to do. You should not need to access the ui pointer in your other dialog at all. Ui pointers are meant to be hidden inside the widget classes that define them, so that they can access the signals, slots, and properties of the widgets defined in the ui file.

    To invoke a second dialog as a response to a button click in the first dialog, all you need to do is something like this:

    Qt Code:
    1. // Dialog1.cpp:
    2. #include "Dialog1.h"
    3. #include "Dialog2.h"
    4.  
    5. Dialog1::Dialog1( QWidget * parent )
    6. : QDialog( parent )
    7. , ui( new Ui::Dialog1 )
    8. {
    9. ui->setupUi( this );
    10.  
    11. connect( ui->someButton, SIGNAL( clicked() ), this, SLOT( showDialog2() ) );
    12. }
    13.  
    14. void Dialog1::showDialog2()
    15. {
    16. Dialog2 dlg2( this );
    17. dlg2->exec();
    18. }
    To copy to clipboard, switch view to plain text mode 

    where of course, you have defined the showDialog2 slot correctly in the Dialog1.h header. The "ui" pointers in the Dialog1 and Dialog2 classes should be declared as private, since there is absolutely no reason to access them from outside of the class the uses them.

    If there are any signals or slots in Dialog2 that need to be "watched" from inside of Dialog1, then set up the connections in showDialog2(). These will automatically be disconnected when dlg2 goes out of scope at the end of showDialog2().
    That's similar to what I originally tried, but I was getting linker errors...

    dialog.obj:-1: error: LNK2019: unresolved external symbol "public: virtual __thiscall settings::~settings(void)" (??1settings@@UAE@XZ) referenced in function "public: void __thiscall Dialog::showSettings(void)" (?showSettings@Dialog@@QAEXXZ)

    dialog.obj:-1: error: LNK2019: unresolved external symbol "public: __thiscall settings::settings(class QWidget *)" (??0settings@@QAE@PAVQWidget@@@Z) referenced in function "public: void __thiscall Dialog::showSettings(void)" (?showSettings@Dialog@@QAEXXZ)

    release\sim.exe:-1: error: LNK1120: 2 unresolved externals

  8. #8
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Using 2 ui files in a project

    That's because you are trying to access some "Ui::settings" object. I have no clue what that is, and it is probably a bad design to try to access it in the way that you are doing, whatever it is.

    What is it that you really want to do?

  9. #9
    Join Date
    Dec 2012
    Posts
    27
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Using 2 ui files in a project

    Quote Originally Posted by d_stranz View Post
    That's because you are trying to access some "Ui::settings" object. I have no clue what that is, and it is probably a bad design to try to access it in the way that you are doing, whatever it is.

    What is it that you really want to do?
    Click a pushbutton and have it create a window from the ui file.

    I basically copied the code that you posted, and I got the errors I posted before:

    Qt Code:
    1. #ifndef DIALOG_H
    2. #define DIALOG_H
    3.  
    4. #include <QDialog>
    5. #include <QtCore>
    6. #include <QtGui>
    7. #include "settings.h"
    8.  
    9. namespace Ui {
    10. class Dialog;
    11. }
    12.  
    13. class Dialog : public QDialog
    14. {
    15. Q_OBJECT
    16.  
    17. public:
    18. Ui::Dialog *ui;
    19. explicit Dialog(QWidget *parent = 0);
    20. ~Dialog();
    21.  
    22. private slots:
    23. void on_pushButton_clicked();
    24. };
    25.  
    26. #endif // DIALOG_H
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. #include "dialog.h"
    2. #include "ui_dialog.h"
    3. #include "settings.h"
    4.  
    5. Dialog::Dialog(QWidget *parent):
    6. QDialog(parent),
    7. ui(new Ui::Dialog)
    8. {
    9. ui->setupUi(this);
    10. }
    11.  
    12. void Dialog::on_pushButton_clicked(){ //settings
    13. settings a(this);
    14. a.exec();
    15. }
    To copy to clipboard, switch view to plain text mode 

  10. #10
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Using 2 ui files in a project

    create a window from the ui file
    I don't know what that means. The moc compiler converts the XML definition in the .ui file into C++ code, which is then compiled and linked into your executable. At run-time the Qt meta-object system executes that compiled code and instantiates QWidgets and layouts, sets their properties, and establishes connections between signals and slots. That's what the "ui->setupUi( this )" line does behind the scenes.

    As far as I know, the only way to replicate this functionality at run-time (e.g. go from uncompiled XML code in a .ui file to running QWidget instances) is to use the QUiLoader or QFormBuilder classes.

    Qt Code:
    1. void Dialog::on_pushButton_clicked()
    2. { //settings
    3. settings a(this);
    4. a.exec();
    5. }
    To copy to clipboard, switch view to plain text mode 

    What is this "settings" class you are trying to create and exec()? Is that the name of your second dialog class? If it is, there is probably something wrong with the way it has been declared or implemented, but since you don't show the code for "settings.h" or "settings.cpp", there's no way to tell.

    What happens if you use QFileDialog instead of "settings"?

    Qt Code:
    1. #include <QFileDialog>
    2.  
    3. void Dialog::on_pushButton_clicked()
    4. { //settings
    5. QFileDialog a(this);
    6. a.exec();
    7. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by d_stranz; 4th January 2013 at 17:19.

  11. #11
    Join Date
    Dec 2012
    Posts
    27
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Using 2 ui files in a project

    Quote Originally Posted by d_stranz View Post
    Qt Code:
    1. void Dialog::on_pushButton_clicked()
    2. { //settings
    3. settings a(this);
    4. a.exec();
    5. }
    To copy to clipboard, switch view to plain text mode 

    What is this "settings" class you are trying to create and exec()? Is that the name of your second dialog class? If it is, there is probably something wrong with the way it has been declared or implemented, but since you don't show the code for "settings.h" or "settings.cpp", there's no way to tell.

    What happens if you use QFileDialog instead of "settings"?

    Qt Code:
    1. #include <QFileDialog>
    2.  
    3. void Dialog::on_pushButton_clicked()
    4. { //settings
    5. QFileDialog a(this);
    6. a.exec();
    7. }
    To copy to clipboard, switch view to plain text mode 
    The settings class is the second dialog class. I added the settings.h and settings.cpp files and straight away it wouldn't compile, even with the default code. Using QFileDialog compiles and works fine.

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

    settings.cpp:
    Qt Code:
    1. #include "settings.h"
    2. #include "ui_settings.h"
    3.  
    4. settings::settings(QWidget *parent) :
    5. QDialog(parent),
    6. ui(new Ui::settings) //error: C2512: 'Ui::settings' : no appropriate default constructor available
    7. {
    8. }
    9.  
    10. settings::~settings(){
    11. delete ui;
    12. }
    To copy to clipboard, switch view to plain text mode 

  12. #12
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Using 2 ui files in a project

    ui(new Ui::settings) //error: C2512: 'Ui::settings' : no appropriate default constructor available
    There is probably something wrong with the code generated by the moc compiler to build the ui .h and .cpp files. Have you done a clean rebuild of everything in your project? Is your ui file correct?

    The compiler error says that you have declared some C++ class called "settings" that lives in the "Ui" namespace, but you haven't provided any code that tells the compiler how to create one (using new). This implies that the name in your ui file is not "settings" but is something else. Have you opened "ui_settings.h" in your editor and looked at the code moc is generating for you?

    In my personal coding style, I do not consider it to be a good practice to use the same name for both the Ui class and the QWidget classes (you have used "settings" for both). I always choose different (but related names) to avoid confusion about which class is being used in a given context. So, in my case, I would use the name "SettingsDlg" or "SettingsDialog" as the name of the derived QDialog class. (The C++ compiler can keep it all straight - it is the humans who get confused easily).

    Also, there is no reason why the "ui" pointer member variable should be public; it should almost always be a private (or at best, protected) member. If you need to access QWidget instances that are declared in the ui code, then it is always better to create access functions for that purpose:

    Qt Code:
    1. QPushButton * SettingsDialog::getPushbutton() const
    2. {
    3. return ui->pushbutton;
    4. }
    To copy to clipboard, switch view to plain text mode 

    If you write any code that is intended for use by other people, directly exposing the ui pointer as you have done is an invitation to abuse. Suppose someone decided that they would replace the ui->pushbutton pointer with a pointer to a QTableWidget instead? Exposing ui as a public member variable allows that to happen. Creating an access function (getPushbutton()) lets them retrieve the pushbutton instance (and mess with its properties), but they can't change the pointer itself. (They could delete it, but that's another issue).

  13. The following user says thank you to d_stranz for this useful post:

    ben1996123 (4th January 2013)

  14. #13
    Join Date
    Dec 2012
    Posts
    27
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Using 2 ui files in a project

    Quote Originally Posted by d_stranz View Post
    Also, there is no reason why the "ui" pointer member variable should be public; it should almost always be a private (or at best, protected) member.
    Yeah I know, not sure why I changed it, I guess I was becoming desperate and was just trying random stuff hoping it would work

    Anyway, I fixed it now. I guess there must have been something wrong with the ui file; I deleted it created a new one and it works fine now.

  15. #14
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Using 2 ui files in a project

    I guess I was becoming desperate and was just trying random stuff hoping it would work
    That's never a good tactic. How do you decide which random thing (or combination of them) was the one that actually made it work? The compiler is usually pretty smart, it is just hard to figure out sometimes what it is trying to tell you, especially when you are in the mind-set that says, "There's nothing wrong with this code."

  16. #15
    Join Date
    Dec 2012
    Posts
    27
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Using 2 ui files in a project

    Quote Originally Posted by d_stranz View Post
    That's never a good tactic. How do you decide which random thing (or combination of them) was the one that actually made it work? The compiler is usually pretty smart, it is just hard to figure out sometimes what it is trying to tell you, especially when you are in the mind-set that says, "There's nothing wrong with this code."
    Yeah I know... I usually don't do it...

    Quote Originally Posted by d_stranz View Post
    If there are any signals or slots in Dialog2 that need to be "watched" from inside of Dialog1, then set up the connections in showDialog2(). These will automatically be disconnected when dlg2 goes out of scope at the end of showDialog2().
    For this, I've connected the signals and slots, but when I open the settings window and click on pushButton_3, it runs the code correctly but it also runs the code that is supposed to run when I click on pushButton_3 in the dialog window. Do I have to rename all of the widgets in the second window to avoid this or am I just doing something wrong?

  17. #16
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Using 2 ui files in a project

    am I just doing something wrong?
    You're doing something wrong.

    pushButton_3 is a member of the "settings" dialog ui? Do you have a pushButton_3 that is also a member of the first "dialog" class ui? These are independent.

    It looks like you are using Qt Designer to set up the connections between signals and slots. Are you sure you are connecting together the right button instances in the designer? Sounds to me as though you have connected the clicked() signal from the pushButton_3 in "settings" to two different slots, one in "settings" and one in "Dialog1". In this case, clicking the pushButton_3 in settings will cause two slots to be executed.

    I usually like to set up my connections in code; personal preference, but it lets me see in one place what signals and slots are connected, rather than having to look in both a C++ file and a UI file to be sure of what is going on.

  18. #17
    Join Date
    Dec 2012
    Posts
    27
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Using 2 ui files in a project

    Quote Originally Posted by d_stranz View Post
    pushButton_3 is a member of the "settings" dialog ui? Do you have a pushButton_3 that is also a member of the first "dialog" class ui? These are independent.
    Yes, there are 2 buttons called pushButton_3, in separate classes.

    Quote Originally Posted by d_stranz View Post
    It looks like you are using Qt Designer to set up the connections between signals and slots. Are you sure you are connecting together the right button instances in the designer?
    To set up the signals and slots, I right clicked on pushButton_3 in settings.ui and clicked on Go to slot.

    Quote Originally Posted by d_stranz View Post
    Sounds to me as though you have connected the clicked() signal from the pushButton_3 in "settings" to two different slots, one in "settings" and one in "Dialog1". In this case, clicking the pushButton_3 in settings will cause two slots to be executed.

    I usually like to set up my connections in code; personal preference, but it lets me see in one place what signals and slots are connected, rather than having to look in both a C++ file and a UI file to be sure of what is going on.
    Hmm... Not sure how I could have done that...

    Is there any way to see/modify all the signals and slots that have been added in Qt Designer?

  19. #18
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Using 2 ui files in a project

    Is there any way to see/modify all the signals and slots that have been added in Qt Designer?
    Probably, but it is easier just to open the .ui file in a text editor and examine the connections part of the XML (usually near the end of the file). Or run the program in debug mode and print out the identity of the sender in each of the slots. If the sender is the same in both slots when you click on the pushbutton in the settings dialog, then somehow you managed to connect the wrong button to one of them.

    It is a really, really good practice to name your UI controls something sensible and meaningful, rather than meaningless names like "pushbutton_3" at Qt Designer does by default. You can easily rename the widgets in the designer - just click on the name in the properties and change it. When you end up with multiple dialogs, and all of the pushbuttons are named "1", "2", "3", ... it is easy to get yourself confused, and impossible to remember when looking at the code what "pushbutton_1" does in this dialog vs. what the button with the same name does in a completely different dialog.

    The problems you are having are the main reason I said I prefer to set up my connections in code, rather than use the designer to do it. It may be easier to use the designer, but after you are done, there is no way to look at your C++ code and tell at a glance what's going on. You have to look in several places to figure it out, and changing it leads to more places to mess up. When you do it in code in the dialog constructor, it's dead simple and obvious what is going on:

    Qt Code:
    1. connect( ui->showSettingsBtn, SIGNAL( clicked() ), this, SLOT( onShowSettings() ) );
    To copy to clipboard, switch view to plain text mode 

    The button is named something sensible, easy to remember, and obvious what happens when it is clicked, and the slot is named similarly.
    Last edited by d_stranz; 6th January 2013 at 20:39.

  20. The following user says thank you to d_stranz for this useful post:

    ben1996123 (6th January 2013)

  21. #19
    Join Date
    Dec 2012
    Posts
    27
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Using 2 ui files in a project

    Quote Originally Posted by d_stranz View Post
    Probably, but it is easier just to open the .ui file in a text editor and examine the connections part of the XML (usually near the end of the file). Or run the program in debug mode and print out the identity of the sender in each of the slots. If the sender is the same in both slots when you click on the pushbutton in the settings dialog, then somehow you managed to connect the wrong button to one of them.

    It is a really, really good practice to name your UI controls something sensible and meaningful, rather than meaningless names like "pushbutton_3" at Qt Designer does by default. You can easily rename the widgets in the designer - just click on the name in the properties and change it. When you end up with multiple dialogs, and all of the pushbuttons are named "1", "2", "3", ... it is easy to get yourself confused, and impossible to remember when looking at the code what "pushbutton_1" does in this dialog vs. what the button with the same name does in a completely different dialog.

    The problems you are having are the main reason I said I prefer to set up my connections in code, rather than use the designer to do it. It may be easier to use the designer, but after you are done, there is no way to look at your C++ code and tell at a glance what's going on. You have to look in several places to figure it out, and changing it leads to more places to mess up. When you do it in code in the dialog constructor, it's dead simple and obvious what is going on:

    Qt Code:
    1. connect( ui->showSettingsBtn, SIGNAL( clicked() ), this, SLOT( onShowSettings() ) );
    To copy to clipboard, switch view to plain text mode 

    The button is named something sensible, easy to remember, and obvious what happens when it is clicked, and the slot is named similarly.
    Thanks for the advice; I remade both ui files and named all the widgets and it works fine now.

  22. #20
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Using 2 ui files in a project

    Thanks for the advice
    Sorry if I sound "preachy"; I went through this same Qt learning curve 5 or so years ago and had all the same problems. I still run into head-scratching situations. There's a lot to learn before you reach the level of competence of ChrisW, Wysota, Santosh, and some of the others on this forum.

Similar Threads

  1. Replies: 1
    Last Post: 15th August 2011, 23:26
  2. Replies: 1
    Last Post: 3rd December 2009, 23:34
  3. example project with multiple .ui files
    By navid in forum Newbie
    Replies: 1
    Last Post: 31st October 2009, 18:25
  4. QMake Project Files....
    By TemporalBeing in forum Qt Programming
    Replies: 2
    Last Post: 6th May 2009, 16:15
  5. visual studio project files - adding extra files
    By luf in forum Qt Programming
    Replies: 3
    Last Post: 13th June 2008, 21:05

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.