views:

452

answers:

1

So I have a modal dialog:

class GraphChooser : public QDialog
{

Q_OBJECT

public:
    GraphChooser(QWidget * parent = 0);
    virtual ~GraphChooser();
    void addGraphItem(QString factoryKey, QString graphDescription);

public slots:
    void graphConfirmed(void);
    void showDialog(void) { exec(); };

private:
    QMap<QString, QString> graphNameToFactoryMap_;
    Ui::GraphChooser ui;


signals:
    void graphSelected(QString& selected);

};

Which I hook up to a button to run

connect(dataForm_.btnAddWindow, SIGNAL(clicked()),
  &graphChooser_, SLOT(exec()));

And the dialog is not modal. I have also tried setModal(true) with a plain old show(). Anything else I should watch out for?

+1  A: 

You must set the parent widget when you create the dialog. Otherwise, the dialog has no idea what it should be modal to.

Aaron Digulla
Or you can set the QDialog as ApplicationModal using the SetModality(Qt::Modality) function with Qt::ApplicationModal
Patrice Bernassola