Qt 将拆分器句柄设置为QScrollArea角落小部件?

Qt 将拆分器句柄设置为QScrollArea角落小部件?,qt,pyqt,pyqt4,qsplitter,Qt,Pyqt,Pyqt4,Qsplitter,我尝试在Mac finder中显示文件和文件夹,如列视图 我能够在ListView和QFileSystemModel的帮助下获得基本结构。然后,我将拆分器句柄设置为滚动区域的角部件。我这里有两个问题 调整listview的大小时,拆分器控制柄消失 即使将拆分器控制柄宽度设置为0,我也可以看到 列表视图 您能使用QColumnView吗?正是这样。 您能使用QColumnView吗?正是这样。 是的,我一直在寻找创建这种小部件的方法。谢谢顺便说一句,我在发送的程序中面临两个问题。这是Qt

我尝试在Mac finder中显示文件和文件夹,如列视图

我能够在ListView和QFileSystemModel的帮助下获得基本结构。然后,我将拆分器句柄设置为滚动区域的角部件。我这里有两个问题

  • 调整listview的大小时,拆分器控制柄消失
  • 即使将拆分器控制柄宽度设置为0,我也可以看到 列表视图

您能使用QColumnView吗?正是这样。


您能使用QColumnView吗?正是这样。


是的,我一直在寻找创建这种小部件的方法。谢谢顺便说一句,我在发送的程序中面临两个问题。这是Qt问题吗?是的,我一直在寻找创建这种小部件的方法。谢谢顺便说一句,我在发送的程序中面临两个问题。这是Qt问题吗?
# -*- coding: utf-8 -*-

from PyQt4 import QtCore, QtGui
import os

try:
    _fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
    def _fromUtf8(s):
        return s

try:
    _encoding = QtGui.QApplication.UnicodeUTF8
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig)

class PopulateList(QtGui.QDialog):
    def __init__(self,parent=None):
        super().__init__(parent)
        self.ui = Ui_Form()
        self.ui.setupUi(self)
        self.setModel()
        self.show()

        self.ui.splitter.setHandleWidth(0)#not working
        self.ui.listView.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
        self.ui.listView.setCornerWidget(self.getCornerWidget(self.ui.splitter))

        self.ui.closePushButton.clicked.connect(self.close)
        self.ui.listView.clicked.connect(self.showSubFiles)

    def getCornerWidget(self, splitter):
        self.handle=splitter.handle(1)
        layout=QtGui.QHBoxLayout(self.handle)
        layout.setSpacing(0)
        layout.setMargin(0)

        for i in range(0,2):
            line = QtGui.QFrame(self.handle)
            line.setFrameShape(QtGui.QFrame.VLine)
            layout.addWidget(line)

        return self.handle

    def showSubFiles(self, index):
        root_path = self.model.fileInfo(index).absoluteFilePath()
        self.model1=QtGui.QFileSystemModel()
        self.model1.setRootPath(root_path)
        self.ui.listView_1.setModel(self.model1)
        self.ui.listView_1.setRootIndex(self.model1.index(root_path))

    def setModel(self):
        root_path=os.path.expanduser("~")
        self.model=QtGui.QFileSystemModel()
        self.model.setRootPath(root_path)
        self.model.setFilter(QtCore.QDir.NoDotAndDotDot | QtCore.QDir.Dirs)
        self.ui.listView.setModel(self.model)
        self.ui.listView.setRootIndex(self.model.index(root_path))

class Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName(_fromUtf8("Form"))
        Form.resize(602, 365)
        self.verticalLayout = QtGui.QVBoxLayout(Form)
        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
        self.splitter = QtGui.QSplitter(Form)
        self.splitter.setOrientation(QtCore.Qt.Horizontal)
        self.splitter.setObjectName(_fromUtf8("splitter"))
        self.listView = QtGui.QListView(self.splitter)
        self.listView.setObjectName(_fromUtf8("listView"))
        self.listView_1 = QtGui.QListView(self.splitter)
        self.listView_1.setObjectName(_fromUtf8("listView_1"))
        self.verticalLayout.addWidget(self.splitter)
        self.horizontalLayout = QtGui.QHBoxLayout()
        self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
        spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)
        self.closePushButton = QtGui.QPushButton(Form)
        self.closePushButton.setObjectName(_fromUtf8("closePushButton"))
        self.horizontalLayout.addWidget(self.closePushButton)
        self.verticalLayout.addLayout(self.horizontalLayout)
        self.verticalLayout.setStretch(0, 1)

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)

    def retranslateUi(self, Form):
        Form.setWindowTitle(_translate("Form", "Form", None))
        self.closePushButton.setText(_translate("Form", "Close", None))


if __name__ == "__main__":
    import sys
    app = QtGui.QApplication(sys.argv)
    listView=PopulateList()
    sys.exit(app.exec_())
import sys
from PyQt5 import QtWidgets, QtCore
app = QtWidgets.QApplication(sys.argv)
model = QtWidgets.QFileSystemModel()
view = QtWidgets.QColumnView()
view.setModel(model)
model.setRootPath("/")
view.show()
sys.exit(app.exec())