Yergei
Yergei

Reputation: 11

qt Window make no modal (Windows)

There are two windows in my qt app, it's main and settings window. When i create Settings Window, i can't use main window, because my new window is modal, and i need to use two windows. How do i make my window no modal?


I use this code:

String inputDir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), 
"/home", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);

I press on my bar and show my Setting window

//Input dir
void SecondWindow::on_pushButton_3_clicked()
{

    inputDir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), "/home", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);


    qDebug() << inputDir;

    ui->lineEdit_3->setText(inputDir);
}

I create this form to get directory which i choosen. And as result of this code: i create a modal settings window.


I see show(), but i don't understand how can i use show() in my situation.

How can i make my new Settings Window as modal window?

Upvotes: 1

Views: 217

Answers (1)

AnthonySimons
AnthonySimons

Reputation: 110

Your second window should inherit QWidget (:public QWidget) and you can use its show() method to show it

QWidget* w = new QWidget();
w->show();

Upvotes: 1

Related Questions