Slots and Connection of Forms...
Hi,
So I have a standalone application which has a QMainWindow. I created another application which is also a QMainWindow. I tried linking them using a button but it did not work. I then changed the second application to QDialog and then the button worked! But since I changed it from QMainWindow to QDialog, the slots stopped working on the new application (I guess the dialog cannot have many buttons..)
Anyway, how do I get this working so that the first QMainWindow opens the second QMainWindow or QDialog AND the buttons in the second application still work..?
Thanks.
Re: Slots and Connection of Forms...
It does not matter if it is a QDialog or a QMainWindow. So can you show us your code which is not working for both solution.
Re: Slots and Connection of Forms...
First app: MainWin
Code:
{
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();
}
Second app: Second
Code:
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!");
}
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.
Re: Slots and Connection of Forms...
in second the SLOT is a
Code:
void Second::func_clicked()
and you have a
Code:
void discovery::func_clicked()
Maybe the discovery is a relic from the previous implemantation?
(the same for the destructor. Does it compile???)
Check this:
http://www.qtcentre.org/faq.php?faq=qt_signalslot
Re: Slots and Connection of Forms...
If these two QWidgets are in separate applications, as both the first and third posts both state/imply, then there is no amount of trickery that is going to make a signal in one trigger a slot in the other.
Re: Slots and Connection of Forms...