Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 6

Qt-interest Archive, February 2007
Destructive Closing of a Dialog displaying Message


Message 1 in thread

Hi All,

I am facing a problem when closing a (destructive close) dialog using a
timer's timeout signal. I have a dialog Box having a single button. The
button is used for displaying a message box. The problem is that if
timer is used to close the dialog when the message box is displayed, the
application goes for a segmentation fault. I am posting the source code
for this sample dialog.
--------
MainFrame::MainFrame()
: QDialog()
{
this->setWFlags(Qt::WDestructiveClose);
qb = new QPushButton("Click Me",this,"qb");
connect(qb,SIGNAL(clicked()),this,SLOT(buttonClked()));
qtime = new QTimer(this,"qtime");
qtime->start(4000,TRUE);
connect(qtime,SIGNAL(timeout()),this,SLOT(close()));
}

void MainFrame::buttonClked()
{
QMessageBox::information(this,"Button","Look");
}
---------------
My main.cpp looks like the following...
NOTE :: MainFrame is intentionally not kept as mainwidget of the
application.
---------------
int main(int argc,char* argv[])
{
QApplication qapp(argc,argv);
MainFrame *mf = new MainFrame();
mf->show();
return qapp.exec();
}
--------------
So after 4 seconds, the application halts with seg fault if the
messageBox is visible...otherwise it behaves just fine....
Can nybody help ?



-- 
 [ signature omitted ]