Hi, I have two QListWidgets living in a QSplitter. I need the items to be editable. Some of the item labels are longer than the visible label.When I edit one, it's selection border extends right across the splitter like this:
It seems that the selection box is as large as the longest item label in the list.
How can I control this so it stays within it's own splitter space? Attached is the sample code. Cheers, frank
#!/usr/bin/env python import Analysis from PySide import QtGui, QtCore class FileAnalyserPanel(QtGui.QDialog): def __init__(self, parent=None): super(FileAnalyserPanel, self).__init__(parent) self.path = QtCore.QDir.homePath() self.buildUI() self.connectSignals() def buildUI(self): '''Sets all the rewuired layouts and widgets''' # layouts mainLayout = QtGui.QVBoxLayout() self.setLayout(mainLayout) topLayout = QtGui.QHBoxLayout() middleLayout1 = QtGui.QHBoxLayout() middleLayout1.setSizeConstraint(QtGui.QLayout.SetFixedSize) middleLayout2 = QtGui.QHBoxLayout() middleLayout2.setSizeConstraint(QtGui.QLayout.SetFixedSize) bottomLayout = QtGui.QHBoxLayout() # widgets pathLabel = QtGui.QLabel('root path') self.pathWidget = QtGui.QLabel() self.pathWidget.setFrameStyle(QtGui.QFrame.StyledPanel| QtGui.QFrame.Sunken) self.pathBtn = QtGui.QPushButton('Set Path...') splitterWidget = QtGui.QSplitter() self.fileListWidgetTotal = QtGui.QListWidget() self.fileListWidgetAccepted = QtGui.QListWidget() self.fileListWidgetRejected = QtGui.QListWidget() splitterWidget.addWidget(self.fileListWidgetAccepted) splitterWidget.addWidget(self.fileListWidgetRejected) labelAccepted = QtGui.QLabel('Accepted') labelAccepted.setSizePolicy(QtGui.QSizePolicy.Policy.Expanding, QtGui.QSizePolicy.Policy.Fixed) labelRejected = QtGui.QLabel('Rejected') labelRejected.setSizePolicy(QtGui.QSizePolicy.Policy.Expanding, QtGui.QSizePolicy.Policy.Fixed) self.counterAccepted = QtGui.QLCDNumber() self.counterAccepted.setSegmentStyle(QtGui.QLCDNumber.Flat) self.counterAccepted.setSizePolicy(QtGui.QSizePolicy.Policy.Expanding, QtGui.QSizePolicy.Policy.Fixed) self.counterRejected = QtGui.QLCDNumber() self.counterRejected.setSegmentStyle(QtGui.QLCDNumber.Flat) self.counterRejected.setSizePolicy(QtGui.QSizePolicy.Policy.Expanding, QtGui.QSizePolicy.Policy.Fixed) # add widgets to layouts topLayout.addWidget(pathLabel) topLayout.addWidget(self.pathWidget, True) topLayout.addWidget(self.pathBtn) topLayout.addWidget(splitterWidget) middleLayout1.addWidget(labelAccepted) middleLayout1.addWidget(labelRejected) middleLayout2.addWidget(self.counterAccepted) middleLayout2.addWidget(self.counterRejected) mainLayout.addLayout(topLayout) mainLayout.addLayout(middleLayout1) mainLayout.addWidget(splitterWidget) mainLayout.addLayout(middleLayout2) mainLayout.addLayout(bottomLayout) def connectSignals(self): self.pathBtn.clicked.connect(self.setPath) def setPath(self): #self.path = QtGui.QFileDialog.getExistingDirectory(self, #'Choose Path to analyse', #self.path) self.pathWidget.setText(self.path) listOfStuff = ['a'*100, 'b'*50, 'c'*20] for f in listOfStuff: item = QtGui.QListWidgetItem(f) item.setFlags(item.flags() | QtCore.Qt.ItemIsEditable) self.fileListWidgetAccepted.addItem(item) if __name__ == '__main__': import sys app = QtGui.QApplication(sys.argv) panel = FileAnalyserPanel() panel.show() panel.raise_() sys.exit(app.exec_())
_______________________________________________ PySide mailing list PySide@qt-project.org http://lists.qt-project.org/mailman/listinfo/pyside