本文整理汇总了Python中PyQt4.QtGui.QListView类的典型用法代码示例。如果您正苦于以下问题:Python QListView类的具体用法?Python QListView怎么用?Python QListView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QListView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _listKeyPressEvent
def _listKeyPressEvent(self, event):
if event.matches(QKeySequence.Delete):
self._deleteList()
elif event.key() == Qt.Key_Escape:
self.playlistList.setCurrentIndex(QModelIndex())
else:
QListView.keyPressEvent(self.playlistList, event)
示例2: keyPressEvent
def keyPressEvent(self, event):
if event.matches(QKeySequence.Delete):
self._removeSelected()
elif event.key() == Qt.Key_Escape:
self.currentList.reset()
else:
QListView.keyPressEvent(self.currentList, event)
示例3: __init__
def __init__(self,parent=None,dataModel = None):
QListView.__init__(self, parent)
self._dataModel = dataModel
self._selectedDisplayMapping = OrderedDict()
self._modelDisplayMapping = OrderedDict()
self._attrModel = QStandardItemModel(self)
示例4: __init__
def __init__(self, parent = None, model=None):
QListView.__init__(self, parent)
if model is None:
model = LayerStackModel()
self.init(model)
示例5: __init__
def __init__(self, qpart, model):
QListView.__init__(self, qpart.viewport())
self.setAttribute(Qt.WA_DeleteOnClose)
self.setItemDelegate(HTMLDelegate(self))
self._qpart = qpart
self.setFont(qpart.font())
self.setCursor(QCursor(Qt.PointingHandCursor))
self.setFocusPolicy(Qt.NoFocus)
self.setModel(model)
self._selectedIndex = -1
# if cursor moved, we shall close widget, if its position (and model) hasn't been updated
self._closeIfNotUpdatedTimer = QTimer(self)
self._closeIfNotUpdatedTimer.setInterval(200)
self._closeIfNotUpdatedTimer.setSingleShot(True)
self._closeIfNotUpdatedTimer.timeout.connect(self._afterCursorPositionChanged)
qpart.installEventFilter(self)
qpart.cursorPositionChanged.connect(self._onCursorPositionChanged)
self.clicked.connect(lambda index: self.itemSelected.emit(index.row()))
self.updateGeometry()
self.show()
qpart.setFocus()
示例6: test_dock_standalone
def test_dock_standalone(self):
widget = QWidget()
layout = QHBoxLayout()
widget.setLayout(layout)
layout.addStretch(1)
widget.show()
dock = CollapsibleDockWidget()
layout.addWidget(dock)
list_view = QListView()
list_view.setModel(QStringListModel(["a", "b"], list_view))
label = QLabel("A label. ")
label.setWordWrap(True)
dock.setExpandedWidget(label)
dock.setCollapsedWidget(list_view)
dock.setExpanded(True)
self.app.processEvents()
def toogle():
dock.setExpanded(not dock.expanded())
self.singleShot(2000, toogle)
toogle()
self.app.exec_()
示例7: AppletNoticeWindow
class AppletNoticeWindow(QWidget):
def __init__(self, controller):
QWidget.__init__(self)
self.__controller = controller
self.__pkglist = []
# setup widgets
self.__vbox_up = QVBoxLayout()
self.__critical_label = QLabel()
self.__critical_label.setWordWrap(True)
self.__list_model = QStringListModel()
self.__list_view = QListView()
self.__list_view.setModel(self.__list_model)
self.__vbox_up.addWidget(self.__critical_label)
self.__vbox_up.addWidget(self.__list_view)
# bottom buttons
self.__vbox = QVBoxLayout()
self.__vbox.addLayout(self.__vbox_up)
self.__button_hbox = QHBoxLayout()
self.__close_button = QPushButton(_("Close"))
self.__launch_pm_button = QPushButton(_("Launch Application Browser"))
self.__button_hbox.addWidget(self.__launch_pm_button)
self.__button_hbox.addWidget(self.__close_button)
self.__vbox.addLayout(self.__button_hbox)
self.setLayout(self.__vbox)
# set window settings
self.resize(400, 200)
self.setWindowTitle(_("Application updates"))
self.connect(self.__close_button, SIGNAL("clicked()"), self.on_close)
self.connect(self.__launch_pm_button, SIGNAL("clicked()"), self.on_pm)
def closeEvent(self, event):
"""
We don't want to kill the window, since the whole app will close
otherwise.
"""
event.ignore()
self.on_close()
def on_pm(self):
self.__controller.launch_package_manager()
def on_close(self):
self.__controller.trigger_notice_window()
def populate(self, pkg_data, critical_txt):
self.__list_model.setStringList(pkg_data)
self.__critical_label.setText(critical_txt)
self.__list_view.update()
示例8: close
def close(self):
"""Explicitly called destructor.
Removes widget from the qpart
"""
self._closeIfNotUpdatedTimer.stop()
self._qpart.removeEventFilter(self)
self._qpart.cursorPositionChanged.disconnect(self._onCursorPositionChanged)
QListView.close(self)
示例9: __init__
def __init__(self, game, parent=None):
QListView.__init__(self, parent)
self.game = None
self.setWindowTitle(m18n('Explain Scores').replace('&', '') + ' - Kajongg')
self.setGeometry(0, 0, 300, 400)
self.model = QStringListModel()
self.setModel(self.model)
StateSaver(self)
self.refresh(game)
示例10: __init__
def __init__(self, parent=None):
super().__init__(parent)
## Attributes
self.data = None
self.distances = None
self.groups = None
self.unique_pos = None
self.base_group_index = 0
## GUI
box = gui.widgetBox(self.controlArea, "Info")
self.info_box = gui.widgetLabel(box, "\n")
## Separate By box
box = gui.widgetBox(self.controlArea, "Separate By")
self.split_by_model = itemmodels.PyListModel(parent=self)
self.split_by_view = QListView()
self.split_by_view.setSelectionMode(QListView.ExtendedSelection)
self.split_by_view.setModel(self.split_by_model)
box.layout().addWidget(self.split_by_view)
self.split_by_view.selectionModel().selectionChanged.connect(
self.on_split_key_changed)
## Sort By box
box = gui.widgetBox(self.controlArea, "Sort By")
self.sort_by_model = itemmodels.PyListModel(parent=self)
self.sort_by_view = QListView()
self.sort_by_view.setSelectionMode(QListView.ExtendedSelection)
self.sort_by_view.setModel(self.sort_by_model)
box.layout().addWidget(self.sort_by_view)
self.sort_by_view.selectionModel().selectionChanged.connect(
self.on_sort_key_changed)
## Distance box
box = gui.widgetBox(self.controlArea, "Distance Measure")
gui.comboBox(box, self, "selected_distance_index",
items=[name for name, _ in self.DISTANCE_FUNCTIONS],
callback=self.on_distance_measure_changed)
self.scene = QGraphicsScene()
self.scene_view = QGraphicsView(self.scene)
self.scene_view.setRenderHints(QPainter.Antialiasing)
self.scene_view.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
self.mainArea.layout().addWidget(self.scene_view)
self.scene_view.installEventFilter(self)
self._disable_updates = False
self._cached_distances = {}
self._base_index_hints = {}
self.main_widget = None
self.resize(800, 600)
示例11: __init__
def __init__(self, parent):
'''
@param parent - QMainWindow
'''
QListView.__init__(self, parent)
self.parentWindow = parent
self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.setSelectionBehavior(QAbstractItemView.SelectItems)
self.viewport().installEventFilter(self)
示例12: __init__
def __init__(self, curve_source):
QListView.__init__(self)
self.curve_source = curve_source
self.setViewMode(QListView.IconMode)
self.setIconSize(QSize(64,64))
self.model = QStandardItemModel()
for curve in curve_source._curves:
self.add_curve(curve)
self.setModel(self.model)
self.setWrapping(True)
self.show()
示例13: keyPressEvent
def keyPressEvent(self, evt):
"""
Protected method implementing special key handling.
@param evt reference to the event (QKeyEvent)
"""
if evt.key() in [Qt.Key_Delete, Qt.Key_Backspace] and \
self.model() is not None:
self.removeSelected()
evt.setAccepted(True)
else:
QListView.keyPressEvent(self, evt)
示例14: __init__
def __init__(self, *args):
QListView.__init__(self, *args)
self.setModel(
AppListModel(
[WebApp.get_local_apps_dir(), utils.libFile('.')],
self))
self.setIconSize(QtCore.QSize(kIconSize, kIconSize))
self.downloadErrShown = False
# To be set through functions
self.win = None
示例15: __init__
def __init__(self, base_maps_list, parent=None, thumb_size=64):
QListView.__init__(self, parent)
self._model = BaseMapsModel(base_maps_list, parent)
self.setModel(self._model)
self.setEditTriggers(QListView.NoEditTriggers)
self.setViewMode(QListView.IconMode)
self.setMovement(QListView.Static)
self.setResizeMode(QListView.Adjust)
#self.setFlow(QListView.TopToBottom)
#self.setWrapping(True)
#self.setSpacing(0)
self.set_thumb_size(thumb_size)