非原生 QFileDialog:将焦点设置到文件列表框,而不是文件名行编辑
我需要在非本机模式下使用 QFileDialog
(以便能够按照建议的此处)。
但是,在该模式下,它的焦点设置在其底部的文件名编辑行。我发现这段代码,我猜它会导致这样的行为:
//https://code.woboq.org/qt5/qtbase/src/widgets/dialogs/qfiledialog.cpp.html
void QFileDialog::setVisible(bool visible)
{
...
if (!d->nativeDialogInUse)
d->qFileDialogUi->fileNameEdit->setFocus();
QDialog::setVisible(visible);
}
但是,我想将焦点设置到文件列表框。即树视图或列表视图,否则该框看起来呈灰色。我不知道为什么Qt开发人员将焦点设置在非原生模式下的文件名行编辑上。也许,这个解决方案背后有一个合理的理由。
我发现了一个相关问题 此处。
I need to use QFileDialog
in a non-native mode (in order to be able to have a multiselect functionality as proposed here).
However, in that mode it has a focus set to the filename edit line at its bottom. I have found this code, which I guess, results in such a behavior:
//https://code.woboq.org/qt5/qtbase/src/widgets/dialogs/qfiledialog.cpp.html
void QFileDialog::setVisible(bool visible)
{
...
if (!d->nativeDialogInUse)
d->qFileDialogUi->fileNameEdit->setFocus();
QDialog::setVisible(visible);
}
However, I would like to set the focus to the file list box. i.e. tree view or list view, as otherwise the box looks grayish. I don't know why Qt developers set the focus to the file name line edit in the non-native mode. Maybe, there is a rationale behind this solution.
I have found a related question here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决方案是重新实现
protected
virtual
QFileDialog::setVisible(bool)
:The solution is to have
protected
virtual
QFileDialog::setVisible(bool)
reimplemented: