QDialog, show() works but not close()
Hi All,
I am updating some existing code and need to close a qDialog that is opened with show(). But when I try to connect to slots, close(), hide() finished(), etc. I get the error
error C2039: 'closeEvent' : is not a member of 'QObject'
Is it possible to close a dialog box without subclassing? Everything is already working and I don't want to re-write the code.
I have a ui QDialog file created with designer holding multiple widgets. When I press my button it opens a modeless dialog window. All I want to add is that when I press another button it will close the dialog, or hide I don't really care. I can close it using the X button, but want to be able to close it when the user does something in the code that renders the dialog no longer valid,
The actual code is large, but here is what I am trying to do. Hope it helps.
Code:
in MyApp.h
#include ui_fullSizeImage.h"
#include "ui_myapp.h"
...
Ui::MyApp m_ui;
Ui::FullSizeDialog m_fullSizeDialog
m_ui.setupUi(this);
m_fullSizeDialog.
setupUi(new QDialog(this, Qt
::WindowMaximizeButtonHint));
// show dialog
connect(m_ui.m_fullScreenButton,
SIGNAL(clicked()),
m_fullSizeDialog.m_dialogWidget->parent(),
SLOT(show()));
And I want to add
Code:
// close dialog, wont compile.
connect(m_ui.m_fullScreenCloseButton,
SIGNAL(clicked()),
m_fullSizeDialog.m_dialogWidget->parent(),
SLOT(close()));
Thanks for your help
Re: QDialog, show() works but not close()
While this is a seriously weird setup, it should work.
You could also keep the pointer to the dialog in a member instead of relying that "parent()" on another object returns it.
Cheers,
_