[Qt-interest] How to close s subwindow?
Louai Al-Khanji
louai.khanji at gmail.com
Tue Nov 10 23:07:31 CET 2009
On Tue, Nov 10, 2009 at 9:55 AM, donglongchao <donglongchao at 163.com> wrote:
> 在2009-11-10,"John McClurkin" <jwm at nei.nih.gov> 写道:
>>donglongchao wrote:
>>> Hi,all
>>>
>>> I have a problem when I develop a MDI app whose UI was create by QT
>>> Designer.The two subwindows of MdiArea were created by right-click on
>>> MdiArea widget and then choose "add subwindow" from the pop menu.When I
>>> start the app,both of the two subwindows appears,but I just want one of
>>> them to appears.So I find two function called void *closeActiveSubWindow
>>> <http://doc.trolltech.com/4.5/qmdiarea.html#closeActiveSubWindow>* ()
>>> and void *closeAllSubWindows
>>> http://doc.trolltech.com/4.5/qmdiarea.html#closeAllSubWindows>* ().But
>>> neither of them is what I need.I just want a function who can close some
>>> certain subwindow I want to close. Is there any function like that ,but
>>> I missed somewhere?
>>
>>If closeActiveSubWindow() or closeAllSubWindows() won't work for you,
>>you will have to write your own function that iterates over all the
>>subwindow to find the one you want to close.
>
> It is not a good news for me.:-(.Maybe I should suggestion the developers of
> QT to add some function like that.:-)
>>Or I could reach my goal(start the app with only one
>>> subwindow appears) through other better way?Any suggestions are welcomed.
>>
>>You can write your app so that only one subwindow appears on startup.
>>You can also write your app so that no subwindows appear on startup.
>>Whether a subwindow is shown depends on whether you call show() on the
>>object.
>>
>
> If you add subwindows by QT Designer as I descributed above(right
> click,choose add subwindow..etc),you would get all your subwindows appears
> when your app start.Because there will be a line of code says
> "mdiAero->addSubwindow(xxx)" in the generated head file named ui_xxx.h which
> will show all the subwindows.Unfortunately we could not modify the ui_xxx.h
> file by hand and I did not find some property to set in QT Designer to
> determine which subwindow should appear and which one should not ,too.I also
> tried the hide() function.But I can only hide the widgets on the subwindow
> but not the subwindow itself.I got a blank subwindow left.:-(.I think the
> only way is remove the subwindows from mdiArea in order to let them
> disappears.If this methond is not conventence,I have to setup my subwindows
> in different .ui files but not intergrate them together in one big .ui file
> like I am doing now.
>
> Any way,thank you for your suggestions,John McClurkin.
>>> Thanks a lot in advance.
>>>
>>> Longchao
>>>
>>>
I played with this for a while. The parent widget of the subwindow
widget can be hidden. So if you add a subwindow called "subwindow1" in
the designer, you can do this:
ui.subwindow1->parentWidget()->hide();
It's ugly, but the API doesn't seem to provide a clean way to do this.
--
- Louai Al-Khanji
More information about the Qt-interest-old
mailing list