0

I have one issue with Qt Close Option when there is QMainWindow is open and on Push button Clicked I am opening one QDialog.Now my requirement is to allow close option is QMainWindow to call closevent of QMainWindow .

Now the senario is when I pressed Button on mainwindow, QDialog open and Close button on upper most right is disabled in QmainWindow. So pls let me know how to enable.

demonplus
  • 5,613
  • 12
  • 49
  • 68
P Kumar
  • 105
  • 1
  • 2
  • 12

2 Answers2

1

So, you don't want to have your GUI blocked while dialog is open, right?

Use a modeless dialog:

void EditorWindow::find()
{
    if (!findDialog) {
        findDialog = new FindDialog(this);
        connect(findDialog, SIGNAL(findNext()), this, SLOT(findNext()));
    }

    findDialog->show();
    findDialog->raise();
    findDialog->activateWindow();
}

Note: The code was taken from the Qt documentation. Notice that we are not using a QDialog::exec() method but just QWidget::show().

Tomas
  • 2,170
  • 10
  • 14
0

Thanks for support you are right it was a problem of modeless

I have Just added as per Example above:

 findDialog->setModel(false);
 findDialog->show();

Before Show I have added setModel(false); and its then working like a charm !!!

Thanks and Regards Praveen Kumar

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
P Kumar
  • 105
  • 1
  • 2
  • 12
  • it should be setModal, not model – Apin Mar 16 '16 at 10:56
  • Hi , Using SetModel I am able to access QMainwindow that is every event that was created was working that is not fine at all. It is allowing each and evry button. – P Kumar Mar 19 '16 at 06:42
  • Now I am Disabling that setModel(false); but again My Question is how to Close Mainwindow from taskbar when QDialog is Open – P Kumar Mar 19 '16 at 06:49