[英]how to hide sidebar in QFileDialog?
I need to hide/disable the sidebar (QSidebar) in the QFileDialog.我需要隐藏/禁用 QFileDialog 中的侧边栏 (QSidebar)。
I've solved this problem using magic-woodoo with d-pointer and editing Qt source code (just like this ).我已经使用带有 d 指针的 magic-woodoo 和编辑 Qt 源代码(就像这样)解决了这个问题。
Is there any more simple way to do it?有没有更简单的方法来做到这一点?
Thanks谢谢
Old-Question,老问题,
I have a python hack:我有一个 python 黑客:
fd = QtGui.QFileDialog()
...
# search for the sidebar and hide it when found
sidebar = None
views = fd.findChildren(QListView)
for obj in views:
if obj.objectName() == "sidebar":
sidebar = obj
break
if sidebar is not None:
sidebar.hide() # hidden away!
# ...now search for the splitter handle and hide it too
splitter = None
splitters = fd.findChildren(QSplitter)
for obj in splitters:
if obj.objectName() == "splitter":
obj.setHandleWidth(0) # hidden -- sort of
break
It is a hacky solution but since I was searching for the same question, I thought I would share the code that I eventually settled for.这是一个 hacky 解决方案,但由于我正在寻找相同的问题,我想我会分享我最终解决的代码。
ps-- I didn't have the chance to compile the above code: sorry about the potential bugs and typos. ps--我没有机会编译上述代码:对于潜在的错误和拼写错误,我深表歉意。 Hopefully you can use the idea here.希望你可以在这里使用这个想法。
QFileDialog uses the native dialog if possible.如果可能,QFileDialog 使用本机对话框。 So if you want to use Qt in a cross platform way the short answer is no.因此,如果您想以跨平台的方式使用 Qt,那么简短的回答是否定的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.