本文整理汇总了Python中PyQt4.QtGui.QListView.setMinimumHeight方法的典型用法代码示例。如果您正苦于以下问题:Python QListView.setMinimumHeight方法的具体用法?Python QListView.setMinimumHeight怎么用?Python QListView.setMinimumHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QListView
的用法示例。
在下文中一共展示了QListView.setMinimumHeight方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: widget
# 需要导入模块: from PyQt4.QtGui import QListView [as 别名]
# 或者: from PyQt4.QtGui.QListView import setMinimumHeight [as 别名]
def widget(self,parent):
td = ListPickerDialog(self, parent)
td.setWindowTitle("Select Server")
td.setAttribute(Qt.WA_DeleteOnClose)
layout = QHBoxLayout();
layout.setContentsMargins(16, 0, 16, 8)
view = self.view()
if not view:
listView = QListView()
listView.setEditTriggers( QAbstractItemView.NoEditTriggers)
listView.setModel(self.model())
listView.setModelColumn(self.modelColumn())
if listView.sizeHintForRow(0)>0:
listView.setMinimumHeight(listView.sizeHintForRow(0) * 5)
view = listView
else:
view.setModel(self.model())
layout.addWidget(view)
self.setView(view)
if self.model():
index = self.model().index(self.currentIndex(), self.modelColumn())
self.selectModelIndex(index)
btnbox = QDialogButtonBox(Qt.Vertical)
btnbox.addButton("Select", QDialogButtonBox.AcceptRole)
addBtn = btnbox.addButton("Add", QDialogButtonBox.ActionRole)
addBtn.clicked.connect(self.addServer)
editBtn = btnbox.addButton("Edit", QDialogButtonBox.ActionRole)
editBtn.clicked.connect(self.editServer)
remBtn = btnbox.addButton("Remove", QDialogButtonBox.ActionRole)
remBtn.clicked.connect(self.remServer)
btnbox.accepted.connect( td.accept)
btnbox.rejected.connect( td.reject)
layout.addWidget(btnbox)
td.setLayout(layout)
return td
示例2: SortedListWidget
# 需要导入模块: from PyQt4.QtGui import QListView [as 别名]
# 或者: from PyQt4.QtGui.QListView import setMinimumHeight [as 别名]
class SortedListWidget(QWidget):
sortingOrderChanged = Signal()
class _MyItemDelegate(QStyledItemDelegate):
def __init__(self, sortingModel, parent):
QStyledItemDelegate.__init__(self, parent)
self.sortingModel = sortingModel
def sizeHint(self, option, index):
size = QStyledItemDelegate.sizeHint(self, option, index)
return QSize(size.width(), size.height() + 4)
def createEditor(self, parent, option, index):
cb = QComboBox(parent)
cb.setModel(self.sortingModel)
cb.showPopup()
return cb
def setEditorData(self, editor, index):
pass # TODO: sensible default
def setModelData(self, editor, model, index):
text = editor.currentText()
model.setData(index, text)
def __init__(self, *args):
QWidget.__init__(self, *args)
self.setContentsMargins(0, 0, 0, 0)
gridLayout = QGridLayout()
gridLayout.setContentsMargins(0, 0, 0, 0)
gridLayout.setSpacing(1)
model = QStandardItemModel(self)
model.rowsInserted.connect(self.__changed)
model.rowsRemoved.connect(self.__changed)
model.dataChanged.connect(self.__changed)
self._listView = QListView(self)
self._listView.setModel(model)
# self._listView.setDragEnabled(True)
self._listView.setDropIndicatorShown(True)
self._listView.setDragDropMode(QListView.InternalMove)
self._listView.viewport().setAcceptDrops(True)
self._listView.setMinimumHeight(100)
gridLayout.addWidget(self._listView, 0, 0, 2, 2)
vButtonLayout = QVBoxLayout()
self._upAction = QAction(
"\u2191", self, toolTip="Move up")
self._upButton = QToolButton(self)
self._upButton.setDefaultAction(self._upAction)
self._upButton.setSizePolicy(
QSizePolicy.Fixed, QSizePolicy.MinimumExpanding)
self._downAction = QAction(
"\u2193", self, toolTip="Move down")
self._downButton = QToolButton(self)
self._downButton.setDefaultAction(self._downAction)
self._downButton.setSizePolicy(
QSizePolicy.Fixed, QSizePolicy.MinimumExpanding)
vButtonLayout.addWidget(self._upButton)
vButtonLayout.addWidget(self._downButton)
gridLayout.addLayout(vButtonLayout, 0, 2, 2, 1)
hButtonLayout = QHBoxLayout()
self._addAction = QAction("+", self)
self._addButton = QToolButton(self)
self._addButton.setDefaultAction(self._addAction)
self._removeAction = QAction("-", self)
self._removeButton = QToolButton(self)
self._removeButton.setDefaultAction(self._removeAction)
hButtonLayout.addWidget(self._addButton)
hButtonLayout.addWidget(self._removeButton)
hButtonLayout.addStretch(10)
gridLayout.addLayout(hButtonLayout, 2, 0, 1, 2)
self.setLayout(gridLayout)
self._addAction.triggered.connect(self._onAddAction)
self._removeAction.triggered.connect(self._onRemoveAction)
self._upAction.triggered.connect(self._onUpAction)
self._downAction.triggered.connect(self._onDownAction)
def sizeHint(self):
size = QWidget.sizeHint(self)
return QSize(size.width(), 100)
def _onAddAction(self):
item = QStandardItem("")
item.setFlags(item.flags() ^ Qt.ItemIsDropEnabled)
self._listView.model().appendRow(item)
self._listView.setCurrentIndex(item.index())
#.........这里部分代码省略.........