[Qt-interest] Designer Created Dialog
Suryakiran Gullapalli
Suryakiran.Gullapalli at ansys.com
Fri Feb 6 07:41:31 CET 2009
Hello,
With Qt - 4.4.3,
I'm designing some dialogs using Qt Designer and from MainWindow's menu,
I show these dialogs as and when required.
it's like this
MainWindow :: MainWindow()
{
...
connect(mainWindowMenuItem, SIGNAL(triggered()), this,
SLOT(showParticularDialog()) ;
...
}
and in showParticularDialog(), I do this.
void MainWindow :: showParticularDialog ()
{
QDialog *dialog = new SomeDialog(this) ;
dialog->show() ;
}
This SomeDialog is declared like this in SomeDialog.hpp
class SomeDialog : public QDialog, private Ui::SomeDialog
{
...
} ;
Ui::SomeDialog is from ui_SomeDialog.h which is created by designer and
uic.
This works fine, but I found an issue with this. Whenever I trigger
mainWindowMenuItem, a new QDialog will be created. Not only the memory
consumption goes up, but also whatever changes I've made in that Dialog
are gone. In the sense that the QDialog object is not persistent.
I tried declaring QDialog* m_someDialog as a member of MainWindow class,
and in its implementation,
MainWindow :: MainWindow ()
{
...
m_someDialog = (QDialog*) 0 ;
connect (mainWindowMenuItem, SIGNAL(triggered()), this,
SLOT(showParticularDialog())) ;
...
}
and in
void MainWindow :: showParticularDialog ()
{
if (!m_someDialog) m_someDialog = new SomeDialog (this) ;
m_someDialog->show() ;
}
This seems to be working, till I close the application. At the time of
closing the application, I get a crash with corrupted heap around mainw.
How to get around this problem.
Thanks in advance,
Surya
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090206/fb90785d/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 959 bytes
Desc: image001.jpg
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090206/fb90785d/attachment.jpe
More information about the Qt-interest-old
mailing list