[SOLVE] How to show QFileDialog at center position Screen?
-
Hi guys,
Please tell me know, how to show @QFileDialog @at center position Screen.
Thanks in advance. -
hi phamvanan ,
check this code , its working fine
@
QFileDialog *dialog = new QFileDialog(this);
QDesktopWidget desk;
QRect screenres = desk.screenGeometry(0);
dialog->setGeometry(QRect(screenres.width()/4,screenres.height() /4,screenres.width()/2,screenres.height()/2));
dialog->show();
@ -
Hi,
Thank you for your answer,
Your code is working fine, I try to dialog->openFileName(); but it do not show center screen.
Please check again for me. -
Hi,
the right way is
@
QFileDialog *dialog = new QFileDialog(this);
QDesktopWidget desk;
QRect screenres = desk.screenGeometry(0); dialog->setGeometry(QRect(screenres.width()/4,screenres.height() /4,screenres.width()/2,screenres.height()/2));
dialog->exec();
@If you call getOpenFileName() a new QFileDialog instance willbe created
-
My code:
@ QFileDialog dialog = new QFileDialog(this);
QDesktopWidget desk;
QRect screenres = desk.screenGeometry(0);
dialog->setGeometry(QRect(screenres.width()/4,screenres.height() /4,screenres.width()/2,screenres.height()/2));
//dialog->exec();
outFile = QFileDialog::getOpenFileName(dialog,
"Title Dialog"),path,
tr("ISO(.iso .ISO);;All Files(.*)")
);@
But it's not showing center screen. -
HI,
how I wrote in previous post, if you call getOpenFileName, a new Dialog instance will be created.
TRY this
@
QFileDialog dialog(this);
dialog.setFileMode(QFileDialog::AnyFile);
dialog.setNameFilter ( tr("ISO(.iso .ISO);;All Files(.)") );QDesktopWidget desk;
QRect screenres = desk.screenGeometry(0);
dialog.setGeometry(QRect(screenres.width()/4,screenres.height() /4,screenres.width()/2,screenres.height()/2));if (dialog->exec())
outFile = dialog.selectedFiles()[0];
@ -
Thanks for your help,
I want use getOpenFileName(....) function so it show with Window's OpenFileDialog , not Qt's OpenFileDialog.----
How to show center monitor but use Window's Dialog
Thanks. -
whenever you are using native dialogs (see the docs if you are unsure) you have no control over the dialogs ... using Qt methods.
Nevertheless i think it would be maybe possible to write the platform-dependent code yourself to show the native dialog (e.g using WinAPI)