[Qt-interest] How to close s subwindow?
donglongchao
donglongchao at 163.com
Wed Nov 11 03:00:02 CET 2009
在2009-11-11,"Louai Al-Khanji" <louai.khanji at gmail.com> 写道:
>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.
>
I also find something in the document here(http://doc.trolltech.com/4.5/qmdiarea.html) says "Note: Once the subwindow has been added, its parent will be the viewport widget of the MdiArea."So I think that is the viewport widget ,not the MdiArea, who are managing all the subWindows.But I do not know how to access this viewport widget from MdiArea directly.Maybe your way is the only one.Not very elegant,but it works very well.
Thank you very much,Louai AI-Khanji.
>--
>- Louai Al-Khanji
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091111/b96e88c5/attachment.html
More information about the Qt-interest-old
mailing list