@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:
// Dialog1.cpp:
#include "Dialog1.h"
#include "Dialog2.h"
Dialog1
::Dialog1( QWidget * parent
), ui( new Ui::Dialog1 )
{
ui->setupUi( this );
connect( ui->someButton, SIGNAL( clicked() ), this, SLOT( showDialog2() ) );
}
void Dialog1::showDialog2()
{
Dialog2 dlg2( this );
dlg2->exec();
}
// Dialog1.cpp:
#include "Dialog1.h"
#include "Dialog2.h"
Dialog1::Dialog1( QWidget * parent )
: QDialog( parent )
, ui( new Ui::Dialog1 )
{
ui->setupUi( this );
connect( ui->someButton, SIGNAL( clicked() ), this, SLOT( showDialog2() ) );
}
void Dialog1::showDialog2()
{
Dialog2 dlg2( this );
dlg2->exec();
}
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().
Bookmarks