Extrakun
Extrakun

Reputation: 19305

QT 4.5 - having problems to get a modal dialog to be modal. What are some pitfalls to be careful about?

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?

Upvotes: 0

Views: 2126

Answers (1)

Aaron Digulla
Aaron Digulla

Reputation: 328604

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

Upvotes: 1

Related Questions