PDA

View Full Version : accessing one dialog from another



rickysts
18th March 2008, 15:54
Hi folks,

I have a simple program with a main window and two dialogs. My file list is main.cpp, mainwindow.cpp, mainwindow.h, dlg1.cpp, dlg1.h, dlg2.cpp and dl2.h.

On mainwindow.cpp, I have this:

d1 = new dlg1;
d2 = new dlg2;

Now, when the user presses a button in dlg1, I would like dlg2 to come up. Perhaps I could just connect the button signal of dlg1 to a function in mainwindow. How do I do this? Any code snippets?

Is there any other way to directly access one dialog from another? The problem is getting dlg1 to know that d2 exists of type dlg2. I don't know how it can be done.

Thanks,

Ricky.

THRESHE
18th March 2008, 16:12
mainwindow.h

{
public slots:
void popup();
}

mainwindow.cpp


d1 = new dlg1;
d2 = new dlg2;

connect (d1->popupButton, SIGNAL(clicked()), this, SLOT(popup()));

void MainWindow::popup()
{
d2->show();
}

rickysts
19th March 2008, 18:58
Thanks! This was easier than expected. I suddenly feel very stupid ;)

Ricky.