当前位置: 首页>>代码示例>>Python>>正文


Python QtCompat.setSectionResizeMode方法代码示例

本文整理汇总了Python中Qt.QtCompat.setSectionResizeMode方法的典型用法代码示例。如果您正苦于以下问题:Python QtCompat.setSectionResizeMode方法的具体用法?Python QtCompat.setSectionResizeMode怎么用?Python QtCompat.setSectionResizeMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Qt.QtCompat的用法示例。


在下文中一共展示了QtCompat.setSectionResizeMode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setData

# 需要导入模块: from Qt import QtCompat [as 别名]
# 或者: from Qt.QtCompat import setSectionResizeMode [as 别名]
	def setData( self, data ) :

		# it could be argued that we should early out here if data is self.getData(),
		# but we can't right now as we're relying on setData() to update everything
		# when the data has been modified in place by some external process, or
		# by self.__removeSelection.

		if data is not None :
			if not isinstance( data, list ) :
				data = [ data ]
			self.__model = _Model( data, self.__tableView, self.getEditable(), self.__headerOverride, self.__columnToolTips, self.__columnEditability )
			self.__model.dataChanged.connect( Gaffer.WeakMethod( self.__modelDataChanged ) )
			self.__model.rowsInserted.connect( Gaffer.WeakMethod( self.__emitDataChangedSignal ) )
			self.__model.rowsRemoved.connect( Gaffer.WeakMethod( self.__emitDataChangedSignal ) )
		else :
			self.__model = None

		self.__tableView.setModel( self.__model )

		if self.__model :

			columnIndex = 0
			haveResizeableContents = False
			for accessor in self.__model.vectorDataAccessors() :
				for i in range( 0, accessor.numColumns() ) :
					delegate = _Delegate.create( accessor.data() )
					delegate.setParent( self.__model )
					self.__tableView.setItemDelegateForColumn( columnIndex, delegate )
					canStretch = delegate.canStretch()
					haveResizeableContents = haveResizeableContents or canStretch
					columnIndex += 1

			QtCompat.setSectionResizeMode(
				self.__tableView.horizontalHeader(),
				QtWidgets.QHeaderView.ResizeToContents if haveResizeableContents else QtWidgets.QHeaderView.Fixed
			)
			self.__tableView.horizontalHeader().setStretchLastSection( canStretch )
			self.__tableView.setSizePolicy(
				QtWidgets.QSizePolicy(
					QtWidgets.QSizePolicy.Expanding if canStretch else QtWidgets.QSizePolicy.Fixed,
					QtWidgets.QSizePolicy.Maximum
				)
			)

			selectionModel = self.__tableView.selectionModel()
			selectionModel.selectionChanged.connect( Gaffer.WeakMethod( self.__selectionChanged ) )

		self.__updateRemoveButtonEnabled()

		# Somehow the QTableView can leave its header in a state where updates are disabled.
		# If we didn't turn them back on, the header would disappear.
		self.__tableView.verticalHeader().setUpdatesEnabled( True )
		self.__tableView.updateGeometry()
开发者ID:boberfly,项目名称:gaffer,代码行数:55,代码来源:VectorDataWidget.py

示例2: __init__

# 需要导入模块: from Qt import QtCompat [as 别名]
# 或者: from Qt.QtCompat import setSectionResizeMode [as 别名]
	def __init__(
		self,
		data=None,
		editable=True,
		header=False,
		showIndices=True,
		minimumVisibleRows=8,
		columnToolTips=None,
		sizeEditable=True,
		columnEditability=None,
		**kw
	) :

		self.__column = GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Vertical )

		GafferUI.Widget.__init__( self, self.__column, **kw )

		# table view

		self.__tableView = _TableView( minimumVisibleRows = minimumVisibleRows )

		self.__tableView.horizontalHeader().setVisible( bool( header ) )
		self.__tableView.horizontalHeader().setMinimumSectionSize( 70 )

		self.__tableView.verticalHeader().setVisible( showIndices )
		QtCompat.setSectionResizeMode( self.__tableView.verticalHeader(), QtWidgets.QHeaderView.Fixed )
		self.__tableView.verticalHeader().setObjectName( "vectorDataWidgetVerticalHeader" )

		self.__tableView.setHorizontalScrollBarPolicy( QtCore.Qt.ScrollBarAlwaysOff )
		self.__tableView.setVerticalScrollBarPolicy( QtCore.Qt.ScrollBarAsNeeded )

		self.__tableView.setSelectionBehavior( QtWidgets.QAbstractItemView.SelectItems )
		self.__tableView.setCornerButtonEnabled( False )

		self.__tableView.setContextMenuPolicy( QtCore.Qt.CustomContextMenu )
		self.__tableView.customContextMenuRequested.connect( Gaffer.WeakMethod( self.__contextMenu ) )

		self.__tableView.verticalHeader().setDefaultSectionSize( 20 )

		self.__tableViewHolder = GafferUI.Widget( self.__tableView )
		self.__column.append( self.__tableViewHolder )

		# buttons

		self.__buttonRow = GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal, spacing = 4 )

		addButton = GafferUI.Button( image="plus.png", hasFrame=False )
		self.__addButtonConnection = addButton.clickedSignal().connect( Gaffer.WeakMethod( self.__addRows ) )
		self.__buttonRow.append( addButton )

		removeButton = GafferUI.Button( image="minus.png", hasFrame=False )
		self.__removeButtonConnection = removeButton.clickedSignal().connect( Gaffer.WeakMethod( self.__removeSelection ) )
		self.__buttonRow.append( removeButton )

		self.__buttonRow.append( GafferUI.Spacer( size = IECore.V2i( 0 ), maximumSize = IECore.V2i( 100000, 1 ) ), expand=1 )
		self.__column.append( self.__buttonRow )

		# stuff for drag enter/leave and drop

		self.__dragEnterConnections = [
			self.dragEnterSignal().connect( Gaffer.WeakMethod( self.__dragEnter ) ),
			addButton.dragEnterSignal().connect( Gaffer.WeakMethod( self.__dragEnter ) ),
			removeButton.dragEnterSignal().connect( Gaffer.WeakMethod( self.__dragEnter ) ),
		]

		self.__dragLeaveConnections = [
			self.dragLeaveSignal().connect( Gaffer.WeakMethod( self.__dragLeave ) ),
			addButton.dragLeaveSignal().connect( Gaffer.WeakMethod( self.__dragLeave ) ),
			removeButton.dragLeaveSignal().connect( Gaffer.WeakMethod( self.__dragLeave ) ),
		]

		self.__dropConnections = [
			self.dropSignal().connect( Gaffer.WeakMethod( self.__drop ) ),
			addButton.dropSignal().connect( Gaffer.WeakMethod( self.__drop ) ),
			removeButton.dropSignal().connect( Gaffer.WeakMethod( self.__drop ) ),
		]

		self.__dragPointer = "values"

		# stuff for drag begin

		self.__borrowedButtonPress = None
		self.__emittingButtonPress = False
		self.__buttonPressConnection = self.__tableViewHolder.buttonPressSignal().connect( Gaffer.WeakMethod( self.__buttonPress ) )
		self.__buttonReleaseConnection = self.__tableViewHolder.buttonReleaseSignal().connect( Gaffer.WeakMethod( self.__buttonRelease ) )
		self.__mouseMoveConnection = self.__tableViewHolder.mouseMoveSignal().connect( Gaffer.WeakMethod( self.__mouseMove ) )
		self.__dragBeginConnection = self.__tableViewHolder.dragBeginSignal().connect( Gaffer.WeakMethod( self.__dragBegin ) )
		self.__dragEndConnection = self.__tableViewHolder.dragEndSignal().connect( Gaffer.WeakMethod( self.__dragEnd ) )

		# final setup

		self.__dataChangedSignal = GafferUI.WidgetSignal()
		self.__editSignal = Gaffer.Signal3()

		if isinstance( header, list ) :
			self.__headerOverride = header
		else :
			self.__headerOverride = None

		self.__columnToolTips = columnToolTips
#.........这里部分代码省略.........
开发者ID:boberfly,项目名称:gaffer,代码行数:103,代码来源:VectorDataWidget.py


注:本文中的Qt.QtCompat.setSectionResizeMode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。