PDA

View Full Version : QDialog - Calling Main Window Function



Preeteesh
20th June 2007, 04:24
Hi,

I have a dilaog which opens from MainWindow, After a User Clicks OK, i need to call a function of Dialog How can i do so..?

Please give some sample code.

wysota
20th June 2007, 05:20
Make a signal-slot connection from the clicked() signal of the button to a custom slot and in that slot call "the function of Dialog". If you make that "function" a slot, you can connect to it directly.

Preeteesh
20th June 2007, 16:55
Sorry i need to call a function of MainWindow on Click on OK Button. Below is code i used

MyClass my;
connect(uiconfig.okButton, SIGNAL(clicked()), &my, SLOT(Test()));

But on click on Button it doesn't goes inside Test function. Please let me know.

Thanks,

jpn
20th June 2007, 17:15
{
MyClass my;
connect(uiconfig.okButton, SIGNAL(clicked()), &my, SLOT(Test()));
} // "my" goes out of scope


Perhaps "my" goes out of scope and no more exists by the time button is clicked. Allocating "my" with keyword new solves the problem.

Preeteesh
20th June 2007, 18:41
It does worked but it didn't got QTreeWidget empty. Actually I have a QTreeWidget in my MainWindow. I open a Dialog from a file open dialog and then it calls that slot which clears the tree by doing ui.treeWidget->clear(), This exectues but tree still doesn't Gets cleared, how should i do it.