本文整理汇总了Python中PyQt4.QtGui.QStandardItemModel方法的典型用法代码示例。如果您正苦于以下问题:Python QtGui.QStandardItemModel方法的具体用法?Python QtGui.QStandardItemModel怎么用?Python QtGui.QStandardItemModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui
的用法示例。
在下文中一共展示了QtGui.QStandardItemModel方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QStandardItemModel [as 别名]
def __init__(self, parent=None):
QtGui.QTableView.__init__(self, parent)
self.model = QtGui.QStandardItemModel(parent=self)
self.model.setHorizontalHeaderLabels(['Source', 'Destination', 'Protoco', 'Info'])
self.setModel(self.model)
self.setColumnWidth(0, 120)
self.setColumnWidth(1, 120)
self.setColumnWidth(2, 100)
self.setColumnWidth(3, 350)
self.setAlternatingRowColors(True)
self.setAutoScroll(True)
self.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) #整行选中
self.setEditTriggers(QtGui.QTableView.NoEditTriggers) #不可编辑
self.setSelectionMode(QtGui.QTableView.SingleSelection) #选择单行
self.show()
示例2: __init__
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QStandardItemModel [as 别名]
def __init__(self, flags):
QtGui.QStandardItemModel.__init__(self)
self.flags = flags
self.header = []
self.data = []
示例3: __init__
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QStandardItemModel [as 别名]
def __init__(self, *args, **kwargs):
super(Outliner, self).__init__(*args, **kwargs)
self.resize(200,500)
self.setObjectName("CustomOutliner")
self.layout = QtGui.QVBoxLayout(self)
self.layout.setMargin(2)
self.model = QtGui.QStandardItemModel()
self.model.setItemPrototype(DagTreeItem())
view = QtGui.QTreeView()
view.setModel(self.model)
view.header().setVisible(False)
view.setEditTriggers(view.NoEditTriggers)
view.setSelectionMode(view.ExtendedSelection)
self.view = view
self.layout.addWidget(self.view)
QtCore.QTimer.singleShot(1, self.initDisplay)
#
# Connections
#
self.view.expanded.connect(self.nodeExpanded)
self.view.selectionModel().selectionChanged.connect(self.selectionChanged)
示例4: update_files_list
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QStandardItemModel [as 别名]
def update_files_list(self):
self.tools = Tools()
# initialize model for inserting to table
model = QtGui.QStandardItemModel(1, 1)
model.setHorizontalHeaderLabels(['File name', 'File size', 'Mimetype', 'File ID'])
self.current_bucket_index = self.file_manager_ui.bucket_select_combo_box.currentIndex()
self.current_selected_bucket_id = self.bucket_id_list[self.current_bucket_index]
i = 0
try:
for self.file_details in self.storj_engine.storj_client.bucket_files(str(self.current_selected_bucket_id)):
item = QtGui.QStandardItem(str(self.file_details['filename'].replace('[DECRYPTED]', "")))
model.setItem(i, 0, item) # row, column, item (StandardItem)
file_size_str = self.tools.human_size(int(self.file_details["size"])) # get human readable file size
item = QtGui.QStandardItem(str(file_size_str))
model.setItem(i, 1, item) # row, column, item (QQtGui.StandardItem)
item = QtGui.QStandardItem(str(self.file_details['mimetype']))
model.setItem(i, 2, item) # row, column, item (QStandardItem)
item = QtGui.QStandardItem(str(self.file_details['id']))
model.setItem(i, 3, item) # row, column, item (QStandardItem)
i = i + 1
self.__logger.info(self.file_details)
except sjexc.StorjBridgeApiError as e:
self.__logger.error(e)
self.file_manager_ui.files_list_tableview.clearFocus()
self.file_manager_ui.files_list_tableview.setModel(model)
self.file_manager_ui.files_list_tableview.horizontalHeader().setResizeMode(QtGui.QHeaderView.Stretch)
示例5: sort
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QStandardItemModel [as 别名]
def sort(self, column, order):
if column == 0:
self._sort_order = order
QtGui.QStandardItemModel.sort(self, column, order)
示例6: initialize_buckets_table
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QStandardItemModel [as 别名]
def initialize_buckets_table(self):
self.storj_engine = StorjEngine() # Init StorjEngine
self.__logger.info('resolving buckets')
# Initialize model for inserting to table
model = QStandardItemModel(1, 1)
model.setHorizontalHeaderLabels(['Name', 'Storage', 'Transfer', 'ID'])
i = 0
try:
for bucket in self.storj_engine.storj_client.bucket_list():
item = QStandardItem(bucket.name)
model.setItem(i, 0, item) # row, column, item (QStandardItem)
item = QStandardItem(str(bucket.storage))
model.setItem(i, 1, item) # row, column, item (QStandardItem)
item = QStandardItem(str(bucket.transfer))
model.setItem(i, 2, item) # row, column, item (QStandardItem)
item = QStandardItem(bucket.id)
model.setItem(i, 3, item) # row, column, item (QStandardItem)
i = i + 1
except sjexc.StorjBridgeApiError as e:
QtGui.QMessageBox.about(
self,
'Unhandled bucket resolving exception',
'Exception: %s' % e)
# Set label of user buckets number
self.bucket_manager_ui.total_buckets_label.setText(str(i))
self.bucket_manager_ui.bucket_list_tableview.setModel(model)
self.bucket_manager_ui.bucket_list_tableview.horizontalHeader().\
setResizeMode(QtGui.QHeaderView.Stretch)
示例7: _set_groups_model
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QStandardItemModel [as 别名]
def _set_groups_model(self, header_labels):
self.groupsModel = QtGui.QStandardItemModel()
self.groupsModel.setHorizontalHeaderLabels(header_labels)