I've thrown together an example here:
https://gist.github.com/justinfx/5926db12d275737e5eb66c7bf7e77e93

QListWidget lets you connect to a double click signal which hands you the
item that was double clicked.
>From there it is trivial to toggle the color as needed.

Justin

On Tue, Sep 20, 2016 at 10:12 PM Alok Gandhi <alok.gandhi2...@gmail.com>
wrote:

> Take a loot at the pyside docs here:
> https://srinikom.github.io/pyside-docs/contents.html
>
> You can also use `PySide.QtGui.QWidget.setStyleSheet(styleSheet)` to
> update the colors.
>
>
> For capturing double click, another approach would be apply an even filter:
>
> def clickable(widget):
>     """Re implementation Double Click Event on a widget"""
>     class MouseDoubleClickFilter(QtCore.QObject):
>         doubleClicked = QtCore.pyqtSignal()
>
>         def eventFilter(self, obj, event):
>             if obj == widget:
>                 if event.type() == QtCore.QEvent.MouseButtonDblClick:
>                     self.doubleClicked.emit()
>                     return True
>
>             return False
>
>     filter = MouseDoubleClickFilter(widget)
>     widget.installEventFilter(filter)
>
>     return filter.doubleClicked
>
>
>
> And then connect this signal:
>
> # Connect the double click signal
> clickable(qlistwidget).connect(handleDoubleClick)
> def handleDoubleClick():
>     # Implement your color update logic here
>     pass
>
>
>
> On Tue, Sep 20, 2016 at 5:48 PM, Juan Tigreros <jtige...@gmail.com> wrote:
>
>> Thanks for the quick response Justin.
>>
>> First, I should mention that I am fairly new to this. With that said,
>> here is what im trying to do.
>>     def doubleClickedItem(self):
>>         """for when an item is double clicked """
>>
>>         theListWidget = self.sender()
>>         currentItem = theListWidget.currentItem()
>>         currentItemText = currentItem.text()
>>         currentItem.setBackground(QtGui.QColor('red'))
>>
>>
>> So, the idea is that I capture the sender item and changed its color to
>> red after is doublecliked. But all the documentation I can find is in c++
>> and have not come across python examples. I am sure its prob very easy to
>> port those examples to python, however, i am still learning and currently
>> stumped by this.
>>
>> On Tuesday, September 20, 2016 at 10:54:50 AM UTC+2, Juan Tigreros wrote:
>>>
>>> Hi everyone!
>>>
>>> Perhaps this is a simple question but I can seemed to succeed at
>>> googling it. Maybe someone here can help?
>>>
>>> I would like to change the text color of a text or background color if
>>> the item in a qlistwidget? I am double clicking on an item and will like to
>>> change the color of it, then change it back once i double clicked in
>>> another item in the list. Any ideas?
>>>
>> --
>> 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 python_inside_maya+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/python_inside_maya/78f19fba-ce1b-4697-b768-e9d686c78b40%40googlegroups.com
>> <https://groups.google.com/d/msgid/python_inside_maya/78f19fba-ce1b-4697-b768-e9d686c78b40%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 the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAPaTLMSbTKJqWpRjf24%3DHCsatoBwXhfe-2guE1eDgH5%2BNmuQFQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAPaTLMSbTKJqWpRjf24%3DHCsatoBwXhfe-2guE1eDgH5%2BNmuQFQ%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 python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0fMbdu8hnhtA-dznogKZwhyopfzFGKoaBh6B7VicUycg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to