View Full Version : set stylesheet for qfiledialog
alizadeh91
17th January 2013, 07:33
Is there any way to set stylesheet for QFileDialog?
Santosh Reddy
18th January 2013, 08:57
Yes, just like any other custom widget.
Just an example
QFileDialog dialog;
dialog.setStyleSheet("QPushButton { background-color: red }");
dialog.show();
alizadeh91
18th January 2013, 09:26
Thanks for reply, Yes that worked but when i use it this way:
QFileDialog fd;
fd.setStyleSheet("QPushButton { background-color: red }");
fd.getSaveFileName(0);
the style is gone! what happens?
Santosh Reddy
18th January 2013, 09:49
getSaveFileName() is a static call, and will by default create a native file dialog, which will not care about stylesheets. You can do this way.
Force use of non-native file dialogs, but only way to apply stylehseet is to apply on the parent (if dialog does not have a parent, you can apply on the applcation, but be warned about the glabal application of styles.
qApp->setStyleSheet("QPushButton { background-color: red }");
QFileDialog::getSaveFileName(0, QString(), QString(), QString(), 0, QFileDialog::DontUseNativeDialog);
alizadeh91
18th January 2013, 10:00
Thanks, Problem solved :)
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.