本文整理汇总了Python中PyQt5.Qt.QTreeView.setObjectName方法的典型用法代码示例。如果您正苦于以下问题:Python QTreeView.setObjectName方法的具体用法?Python QTreeView.setObjectName怎么用?Python QTreeView.setObjectName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.Qt.QTreeView
的用法示例。
在下文中一共展示了QTreeView.setObjectName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: BookWarriorHomepage
# 需要导入模块: from PyQt5.Qt import QTreeView [as 别名]
# 或者: from PyQt5.Qt.QTreeView import setObjectName [as 别名]
class BookWarriorHomepage ( QWidget,Ui_BookWarriorHomepage):
updateSelection = pyqtSignal()
def __init__ (self,model,parent=None):
super(BookWarriorHomepage,self).__init__(parent)
self.setupUi(self)
self.max_vignettes = 20
self.nb_col = 0
self.nb_row = 0
self.vignettes_liste = []
self.model = model
self.settings = Config().instance.settings
self.list_warrior = [] # utilise pour maj selection depuis warrrior layout
def setLeftPage(self):
self.treeView = QTreeView(self)
self.treeView.setObjectName("treeView")
self.left_page_Layout.addWidget(self.treeView)
self.treeView.activated.connect(self.changeCurrentSet)
self.tree_model = TreeModel(self.model)
self.treeView.setModel(self.tree_model)
self.treeView.setWindowTitle("Simple Tree Model")
self.treeView.header().hide()
self.treeView.setAlternatingRowColors(True)
# i = 0
# self.treeKingdom.setColumnCount(3)
# for faction in self.model.factions.values() :
# item_f = QTreeWidgetItem(self.treeKingdom)
# #self.treeKingdom.insertTopLevelItem(i,item_f)
# item_f.setText(i,faction.name)
# i = i +1
# for empire in faction.empires.values():
# item_e = QTreeWidgetItem()
# item_e.setText(i,empire.name)
# item_f.addChild(item_e)
# for kingdom in empire.kingdoms.values():
# item_k = QTreeWidgetItem()
# item_k.setText(i,kingdom.name)
# item_e.addChild(item_k)
# for groupe in kingdom.groupes.values():
# item_g = QTreeWidgetItem()
# item_g.setText(i,groupe.name)
# print ('groupe',groupe.name)
# item_k.addChild(item_g)
def setRightContent (self, list_warrior):
self.list_warrior = list_warrior
for v in self.vignettes_liste :
v.setParent(None)
self.gridLayout.removeWidget(v)
# while self.gridLayout.takeAt(0) != None :
# del self.gridLayout.takeAt(0).widget
# item = self.gridLayout.takeAt(0)
# print ('ll')
# del item
self.nb_col = 0
self.nb_row = 0
self.vignettes_liste = []
for i in range (min(len(list_warrior),self.max_vignettes)):
self.addVignette(list_warrior[i],i)
def updateContent(self):
pass
def addVignette (self,warrior,i):
widget_vignette = QWidget(self.vignettes)
layout_one_vignette = QVBoxLayout(widget_vignette)
layout_one_vignette.setSpacing(0)
layout_one_vignette.setContentsMargins(0, 0, 0, 0)
warrior_button = QPushButton(widget_vignette)
# on met plus car dans le cas du signal clicked on enverra True ou False (0 ou 1)
warrior_button.setObjectName(str(i+2))
warrior_button.clicked.connect(self.parent().goWarriorPage)
sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
warrior_button.setFixedSize(QtCore.QSize(100,120))
warrior_button.setSizePolicy(sizePolicy)
layout_one_vignette.addWidget(warrior_button)
# label
warrior_label = HerosLabel(warrior,widget_vignette)
layout_one_vignette.addWidget(warrior_label)
max_col = 3
groupe_name = warrior.groupe().name
if warrior.masterGroupe() != None :
groupe_name = warrior.masterGroupe().name+"/"+groupe_name
#path = os.path.join(Config().instance.path_to_pic(),faction_name,empire_name,kingdom_name,"Picture",groupe_name,warrior_name
icon = QIcon(warrior.thumb)
#print (basepath+"/"+faction_name+"/"+empire_name+"/"+kingdom_name+"/Picture/"+groupe_name+"/"+warrior.name+"/portrait_thumbnail.jpg")
warrior_button.setIcon(icon)
warrior_button.setIconSize(QtCore.QSize(100,120))
if self.nb_col == 0:
self.nb_row = self.nb_row + 1
#.........这里部分代码省略.........