PDA

View Full Version : MDI Application



martisho
7th May 2009, 14:29
Hi,



please help me, I am begginer using Qt, and i have to do a MDI Application, my application will have a main interface, and several subwindows, and i am using mdiArea. At the beggining the application shows one subwindow but the other should be hidden, and i don´t know how to do this. After pressing some buttons the rest of the subwindows will appear. I have design the subwindows with Qt Designer, adding to the main interface a mdiArea and then subwindows. Please help me, because a i have try a lot of things, and i haven´t got what i want.

Sorry for my english.

Thanks.

wysota
7th May 2009, 17:35
Did you try QWidget::hide()?

martisho
8th May 2009, 13:00
The problem is, at the beggining of the aplication, one subwindow is showed, this subwindow can be opened with a button in the menu bar, but the problem is that if i close that subwindow, and i click on the button of the menu bar, nothing happens. My code is this:


void Interfaz::crearInicio(){

Inicio *sub_inicio = new Inicio;
mdiArea->addSubWindow(sub_inicio);
sub_inicio->setAttribute(Qt::WA_DeleteOnClose);
mdiArea->setActiveSubWindow(qobject_cast<QMdiSubWindow *>(sub_inicio));
sub_inicio->showMaximized();
}

void Interfaz::crearAcciones(){

connect (ui.inicioAct, SIGNAL(triggered()), this, SLOT (crearInicio()));

}

ui.inicio is the button in the menu bar.

wysota
8th May 2009, 13:25
Please provide a minimal compilable example reproducing the problem.

martisho
8th May 2009, 13:48
I have solved the problem, thank you very much.

wysota
8th May 2009, 14:05
Please use the [code] tags and not [qtclass] tags.

Please craft an example code consisting of the main() function and the minimum functionality from your application that reproduces the problem. Make it that calling qmake and make results in a valid executable application.

martisho
12th May 2009, 13:27
Hi again,

i have 5 kinds of subwindows in my application, what i want to do is to check that the application doesn´t open a subwindows if there is a subwindows open of the same kind.

Please help me.

Thank you.

Could you put some general code please?

wysota
12th May 2009, 20:52
Could you put some general code please?

No, this task is so easy you will surely manage to do it yourself. Just store a pointer to the subwindow you create and when you are to open the window again, see if the pointer is valid or not. If so, it means the window is there (although it may be hidden so you might want to show() and raise() it).