QFileDialog not appearing on the top even after using different window flags
-
When the user clicks the browse button I'm doing
QFileDialog *img = new QFileDialog;
img->show();
The Dialog box appears but next time when the user clicks browse button the DialogBox is minimised/opening behind by mainwindow.I tried setting different window flags but they are not working. -
I tried doing this
MainWindow::MainWindow(QWidget *centralWidget) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{ui->setupUi(this);
...........
}getting error /home/tel/Ui_IMP/mainwindow.cpp:17: error: invalid use of non-static member function
ui(new Ui::MainWindow)
^ -
@Sherlin-N-G
It's theQFileDialog
constructor you're needing to change, to give the dialog a parent. You're supposed to be calling e.g.new QFileDialog(mainWindow)
ornew QFileDialog(mainWindow->centralWidget)
. -
i tried
QFileDialog *file = new QFileDialog(MainWindow);
its showing "expected primary-expression before ')' token"also tried this
/home/tel/Ui_IMP/mainwindow.cpp:73: error: expected primary-expression before ‘->’ token
QFileDialog *file = new QFileDialog(MainWindow->centralWidget);
^ -
@Sherlin-N-G
MainWindow
is a class. You need to pass an instance, the instance of yourMainWindow
. That's why I wrotemainWindow
(a variable of yours, whatever it is), notMainWindow
(the class). -
@Sherlin-N-G said in QFileDialog not appearing on the top even after using different window flags:
QFileDialog *file = new QFileDialog(MainWindow->centralWidget);
is there really a variable called
MainWindow
?!
If you are executing this code from within any widget, just passthis
instead. -
solved thankyou