Hi Justin,
here's the code I've used. I attempted to try your
suggestion but haven't got any luck getting it to work. Thanks again for
the time spent !
class PoseListView(QtGui.QListWidget):
def __init__(self, parent=None):
super(PoseListView, self).__init__(parent)
self._parent = parent
# Grid/View settings
self.setViewMode(QtGui.QListView.IconMode)
self.setGridSize(QtCore.QSize(40, 80))
self.setSpacing(10)
self.setMinimumWidth(self.sizeHintForColumn(0))
self.setMouseTracking(True)
self.setStyleSheet("item:hover{background: qlineargradient(x1: 0,
y1: 0, x2: 0, y2: 1,\
stop: 0 #FAFBFE, stop: 1 #DCDEF1);}"
)
for i in range(3):
item = PoseWidget(self)
self.addItem(item)
item.setSizeHint(QtCore.QSize(40, 60))
class PoseWidget(QtGui.QListWidgetItem):
def __init__(self, id, *args, **kwargs):
super(PoseWidget, self).__init__()
self.pose = kwargs.get('pose', None)
# Item settings
self._id = id
self.setText('')
flags = QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled |
QtCore.Qt.ItemIsDragEnabled
self.setFlags(flags)
project_root = cmds.workspace(q=True, rootDirectory=True)
map_dir = os.path.join(project_root, 'data', 'pose_library')
image_path = '{0}{1}'.format(map_dir,'/test.jpg')
pic = QtGui.QPixmap(image_path)
self.setBackground(QtGui.QBrush(image_path))
On Fri, Sep 5, 2014 at 6:58 PM, Justin Israel <[email protected]>
wrote:
> Can you show a small example of how you are setting up your list and items
> and their background? I'm not sure what you mean when you say the
> stylesheet doesn't do anything to your system. If I set a background on the
> items in the list, and then use a stylesheet to control the hover, it seems
> to work just fine.
>
>
> On Sat, Sep 6, 2014 at 12:56 PM, Bay <[email protected]> wrote:
>
>> Hi Justin,
>> thanks once again for your assistance.
>>
>> The issue now is that I'm using an image on the background
>> of the qlistwidgetitem(sort of like a thumbnail in an image viewer), the
>> goal is to achieve a highlight when the mouse is hovering over it. As you
>> say, setStyleSheet does work but unfortunately it will not do anything to
>> the image. And yes, I immediately ran into that problem with the list
>> widget as soon as I implemented it and had to set the background every time
>> my mouse leaves the list widget. I found this likely to be very
>> computationally heavy but no idea how to deal with it. so any advice would
>> be much appreciated.
>>
>> Thank you
>> Gann Boon Bay
>>
>>>
>>> --
>> You received this message because you are subscribed to the Google Groups
>> "Python Programming for Autodesk Maya" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/python_inside_maya/ba3b42e4-716a-4db7-a020-3803d5f922d5%40googlegroups.com
>> <https://groups.google.com/d/msgid/python_inside_maya/ba3b42e4-716a-4db7-a020-3803d5f922d5%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Python Programming for Autodesk Maya" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/python_inside_maya/N8eOmxHAjp4/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1o4zimEN3%3Dt0c2-G7yOfvRDAxDbUfikQ-nJZFEvGB8gA%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1o4zimEN3%3Dt0c2-G7yOfvRDAxDbUfikQ-nJZFEvGB8gA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAO52s0HwpGHGzzjPqgL50f0djs%2Bv50KOuBcpWpLoE6NScnPkWQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.