First app: MainWin
{
dSecond = NULL; // QDialog
ui.setupUi(this);
connect(ui.action_Two, SIGNAL(activated()), this, SLOT(two()));
}
MainWin::~MainWin()
{
}
void MainWin::two()
{
if(!dSecond)
{
uiSecond.setupUi(dSecond); //ui::Second uiSecond;
}
dSecond->exec();
}
MainWin::MainWin(QWidget*p, Qt::WindowFlags f):QMainWindow(p,f)
{
dSecond = NULL; // QDialog
ui.setupUi(this);
connect(ui.action_Two, SIGNAL(activated()), this, SLOT(two()));
}
MainWin::~MainWin()
{
}
void MainWin::two()
{
if(!dSecond)
{
dSecond = new QDialog(this);
uiSecond.setupUi(dSecond); //ui::Second uiSecond;
}
dSecond->exec();
}
To copy to clipboard, switch view to plain text mode
Second app: Second
ui(new Ui::Second)
{
connect(ui->action_button, SIGNAL(clicked()), this, SLOT(func_clicked()));
}
discovery::~discovery()
{
delete ui;
}
void discovery::func_clicked()
{
QMessageBox::warning(0,
"Test",
"Test message. It works!");
}
Second::Second(QWidget *parent) :
QDialog(parent),
ui(new Ui::Second)
{
connect(ui->action_button, SIGNAL(clicked()), this, SLOT(func_clicked()));
}
discovery::~discovery()
{
delete ui;
}
void discovery::func_clicked()
{
QMessageBox::warning(0,"Test", "Test message. It works!");
}
To copy to clipboard, switch view to plain text mode
This way shows the new app when the menu bar item is clicked, but the new app does not show warning message when button is pressed.
Bookmarks