Solved Change QFileDialog Buttons Text
-
Hi i know whit this code i can change text Open buttton :
OpenFile.setLabelText(QFileDialog::Accept, tr("test"));
but how to change text Cancel button?
I test this but don't work :OpenFile.setLabelText(QFileDialog::Reject, tr("Cancell change"));
and how to change button text in save file dialog whit this code :
QString SaveAddress = QFileDialog::getSaveFileName(this, tr("Save File"), ..........)
-
@ARASHz4 said in Change QFileDialog Buttons Text:
I test this but don't work :
OpenFile.setLabelText(QFileDialog::Reject, tr("Cancell change"));Hi,
this should work if you haveQFileDialog OpenFile(parentWidget);
with some parent widget. At least it works in my code.
-Michael. -
yes i set parent :
QFileDialog OpenFile(this);
-
Hi,
I just checked it (after quite some time again) and you are right: it does no longer work in my code, either.For me it seemed to be wrong since I changed from Qt4 to Qt5, but the file dialog itself also looks different, probably a change between the native one and the Qt one.
-Michael. -
-
Yes i now test in Ubuntu & work!
in Qt 5.7.1 & Ubuntu 16.10 work
in Qt 5.7.1 & Windows 10 don't work! -
how to change button text in save file dialog?
-
Hi,
just make it a save dialog by
OpenFile.setAcceptMode(QFileDialog::AcceptSave);
otherwise it should be the same, and probably the same problem with the cancel button.
-Michael. -
BTW: changing the cancel button works (on WIndows) if you do not use the native dialog:
OpenFile.setOption(QFileDialog::DontUseNativeDialog); OpenFile.setLabelText(QFileDialog::Reject, tr("Cancell change"));
BEWARE: the native dialog will display files on a network drive considerably faster than the Qt one.
-Michael. -
Good news: the problem will be fixed in Qt 5.9. But you can include the fix in your current Qt version (I tested with 5.7.1) and make it work right away: https://codereview.qt-project.org/#/c/181737/2/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp.
-Michael.