PDA

View Full Version : setting widget as modal, disables button



munna
24th November 2006, 12:06
Hi,

I have written the following code in the constructor of class that reimplements QWidget




setAttribute(Qt::WA_DeleteOnClose);
setWindowModality(Qt::WindowModal);
setFixedSize(400,120);
setAutoFillBackground(true);

registerButton = new QPushButton(tr("Enter registraion key"),this);



I am trying to get a modal widget (frameless) on top of my mainwindow. Parent of this widget is the mainwindow of the application. But the registerButton is disabled because of setWindowModal.

Anyideas on why the button is disabled and how can I prevent it from getting disabled ?

Thanks a lot

wysota
26th November 2006, 09:34
Are you using this code under Windows?

munna
27th November 2006, 04:37
yes, I am using this under windows.

wysota
27th November 2006, 09:49
And if you rem the window modality line then everything works as expected? It could be some kind of bug... Why don't you use a dialog instead of a widget? If you already have a widget, you can always wrap it into a dialog:

QDialog dlg;
MyWidget *myWidget = new MyWidget;
QVBoxLayout *l = new QVBoxLayout;
l->addWidget(myWidget);
dlg.setLayout(l);
dlg.exec();