Unsolved Prevent dialog from getting input
-
Hello,
I've two screen where parent size is 0,0,480,272 while child is at 60,56,240,130
When child is open parent can be touched.
How to prevent this?
I want that touch are eligible only for the top dialog -
@jigarp
Code? Is your dialog modal?QDialog::exec()
? etc. -
@JonB
No.
I don't how to use it?? -
@jigarp How to use what? exec()?
Check documentation: http://doc.qt.io/qt-5/qdialog.html#exec
This is called a modal dialog: a modal dialog blocks all other windows of the application as long as it is shown.
Using exec() instead of show() you can make your dialog modal.
Like (again) shown in documentation:void EditorWindow::countWords() { WordCountDialog dialog(this); dialog.setWordCount(document().wordCount()); dialog.exec(); }
-
@jsulm
In My case i've creted all the diaglog on startup.
While button presssed i'm showing dialog.
This time i've used
dialog.exec();
instead of show but still background screens can accept touch events.
Here my -
@jigarp What "background screens"? Do you mean other applications or your own application where you start this dialog?
-
@jsulm
In same application different dialog -
@jigarp In what way do these other dialogs accept touch events?
-
@jsulm
Here i've provided my sample code.
You may get an idea from this that how my code is workingParent Window resolution 0,0,480,272
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); sibling1Child = new sibling1(this); this->move(0,0); // 0,0,480,272 sibling1Child->move(0,0); // 0,0,480,272 } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_pushButton_pressed() { sibling1Child->show(); }
Sibling 1 resolution 0,0,480,272
sibling1::sibling1(QWidget *parent) : QDialog(parent), ui(new Ui::sibling1) { ui->setupUi(this); sibling2Child = new sibling2(this); sibling2Child->move(60,56); // 60,56,240,130 } sibling1::~sibling1() { delete ui; } void sibling1::on_pushButton_2_pressed() { sibling2Child->move(60,56); sibling2Child->show(); } void sibling1::on_pushButton_pressed() { this->hide(); }
sibling2 resolution 60,56,240,130
sibling2::sibling2(QWidget *parent) : QDialog(parent), ui(new Ui::sibling2) { ui->setupUi(this); } sibling2::~sibling2() { delete ui; } void sibling2::on_pushButton_pressed() { this->hide(); }
-
@jigarp More interesting information is: how do you show the dialogs?
-
@jsulm
Can you please ellaborate it..
is it like
show() or hide() functions.Else as you mentioned using dialog.exec() function.
I've tried both of them -
@jigarp Well, if you show a dialog using exec() then it should block all other dialogs and main window.
-
@jsulm
I've replaced show() with exec()
But still not working.