[Qt-interest] MDI Question
John McClurkin
jwm at nei.nih.gov
Wed Sep 16 17:51:34 CEST 2009
JD Guzman wrote:
> Hello all,
>
> I have a quick question. I'm making a MDI app and am having a small
> issue with Sub Windows. From the main app window menu bar I create a
> sub window using the following code.
>
> void MainWindow::showPreferences()
> {
> Preferences *prefs = new Preferences;
> ui->mdiArea->addSubWindow(prefs);
> prefs->show();
> }
>
>
> This works fine and the windows shows inside the mdi area. The prefs
> window has a button box and the accepted and rejected signals are
> connected like this:
>
>
> void Preferences::connectActions()
> {
> QObject::connect(m_ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
> QObject::connect(m_ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
> }
>
> void Preferences::accept()
> {
> this->close();
> }
>
> void Preferences::reject()
> {
> this->close();
> }
>
>
> The problem is that when either the slot is called the window remains
> but the contents (which at the moment is only the button box)
> disappear. I then have to press the "X" manually to fully close the
> window. Furthermore if I remove the ui->mdiArea->addSubWindow(prefs)
> call everything works as expected, with the difference that the prefs
> window is no longer in the mdi area.
>
>
> Any ideas?
>
>
> Regards
This is how I close a view that may be in QMdiSubWindow:
> void DataView::closeView(bool checked)
> {
> QWidget *parent = parentWidget();
> if(parent != (QWidget *)NULL) {
> parent->close();
> }
> else {
> close();
> }
> }
More information about the Qt-interest-old
mailing list