Python QListWidget项目/图标之间的间隙
我想消除textureIconChart QListWidget中QListWidget项之间的间隙。它由设置了pixmap图标的项目填充。我正在使用设置为QHBoxLayout的QListWidget,它设置为QVBoxLayoutPython QListWidget项目/图标之间的间隙,python,pyside2,Python,Pyside2,我想消除textureIconChart QListWidget中QListWidget项之间的间隙。它由设置了pixmap图标的项目填充。我正在使用设置为QHBoxLayout的QListWidget,它设置为QVBoxLayout 提供一个我包含的图片来演示这个问题。我只是在寻找用户用来解决问题的方法,而不是调试任何代码。我向您索要代码是因为我发现您在QListWidget中提到QHBoxLayout很奇怪,在我看来,您似乎以特定的方式实现了它,所以我向您索要代码。你在提供MCVE时有问题
提供一个我包含的图片来演示这个问题。我只是在寻找用户用来解决问题的方法,而不是调试任何代码。我向您索要代码是因为我发现您在QListWidget中提到QHBoxLayout很奇怪,在我看来,您似乎以特定的方式实现了它,所以我向您索要代码。你在提供MCVE时有问题吗?我会尝试提供一些代码,我只需要把它从更大的程序中拉出来,看看是否可以使它独立。现在我发现提到QHBoxLayout是不相关的。无论如何,你的代码帮助你理解,从我的理解你想消除图标之间的空间,对吗?
import maya.cmds as cmds
import os
import maya.OpenMayaUI as mui
from PySide2 import QtWidgets,QtCore,QtGui
import shiboken2
class texture_replacer():
def texture_linker_UI(self):
windowName = "name"
if cmds.window(windowName,exists = True):
cmds.deleteUI(windowName, wnd = True)
pointer = mui.MQtUtil.mainWindow()
parent = shiboken2.wrapInstance(long(pointer),QtWidgets.QWidget)
window = QtWidgets.QMainWindow(parent)
window.setObjectName(windowName)
window.setWindowTitle(windowName)
window.setMinimumSize(450,650)
window.setMaximumSize(600,400)
mainWidget = QtWidgets.QWidget()
window.setCentralWidget(mainWidget)
verticalLayout = QtWidgets.QVBoxLayout(mainWidget)
self.textureIconChartLayout = QtWidgets.QVBoxLayout()
textureIconsLayout = QtWidgets.QHBoxLayout()
self.textureIconChartLayout.addLayout(textureIconsLayout)
verticalLayout.addLayout(self.textureIconChartLayout)
self.textureIconChart = QtWidgets.QListWidget()
self.textureIconChart.setViewMode(QtWidgets.QListWidget.IconMode)
self.textureIconChart.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
self.textureIconChart.setDragEnabled(0)
self.textureIconChart.setMaximumWidth(290)
self.populateListWidget()
textureIconsLayout.addWidget(self.textureIconChart)
textureIconsLayout.setSpacing(0)
textureIconsLayout.setContentsMargins(0,0,0,0)
tr = texture_replacer()
tr.texture_linker_UI()